-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(derive): Ensure we don't break compatibility
- Loading branch information
Showing
33 changed files
with
5,284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
use clap::CommandFactory; | ||
use clap::Parser; | ||
#[test] | ||
fn app_name_in_short_help_from_struct() { | ||
#[derive(Parser)] | ||
#[clap(name = "my-cmd")] | ||
struct MyApp {} | ||
|
||
let mut help = Vec::new(); | ||
MyApp::command().write_help(&mut help).unwrap(); | ||
let help = String::from_utf8(help).unwrap(); | ||
|
||
assert!(help.contains("my-cmd")); | ||
} | ||
|
||
#[test] | ||
fn app_name_in_long_help_from_struct() { | ||
#[derive(Parser)] | ||
#[clap(name = "my-cmd")] | ||
struct MyApp {} | ||
|
||
let mut help = Vec::new(); | ||
MyApp::command().write_long_help(&mut help).unwrap(); | ||
let help = String::from_utf8(help).unwrap(); | ||
|
||
assert!(help.contains("my-cmd")); | ||
} | ||
|
||
#[test] | ||
fn app_name_in_short_help_from_enum() { | ||
#[derive(Parser)] | ||
#[clap(name = "my-cmd")] | ||
enum MyApp {} | ||
|
||
let mut help = Vec::new(); | ||
MyApp::command().write_help(&mut help).unwrap(); | ||
let help = String::from_utf8(help).unwrap(); | ||
|
||
assert!(help.contains("my-cmd")); | ||
} | ||
|
||
#[test] | ||
fn app_name_in_long_help_from_enum() { | ||
#[derive(Parser)] | ||
#[clap(name = "my-cmd")] | ||
enum MyApp {} | ||
|
||
let mut help = Vec::new(); | ||
MyApp::command().write_long_help(&mut help).unwrap(); | ||
let help = String::from_utf8(help).unwrap(); | ||
|
||
assert!(help.contains("my-cmd")); | ||
} | ||
|
||
#[test] | ||
fn app_name_in_short_version_from_struct() { | ||
#[derive(Parser)] | ||
#[clap(name = "my-cmd")] | ||
struct MyApp {} | ||
|
||
let version = MyApp::command().render_version(); | ||
|
||
assert!(version.contains("my-cmd")); | ||
} | ||
|
||
#[test] | ||
fn app_name_in_long_version_from_struct() { | ||
#[derive(Parser)] | ||
#[clap(name = "my-cmd")] | ||
struct MyApp {} | ||
|
||
let version = MyApp::command().render_long_version(); | ||
|
||
assert!(version.contains("my-cmd")); | ||
} | ||
|
||
#[test] | ||
fn app_name_in_short_version_from_enum() { | ||
#[derive(Parser)] | ||
#[clap(name = "my-cmd")] | ||
enum MyApp {} | ||
|
||
let version = MyApp::command().render_version(); | ||
|
||
assert!(version.contains("my-cmd")); | ||
} | ||
|
||
#[test] | ||
fn app_name_in_long_version_from_enum() { | ||
#[derive(Parser)] | ||
#[clap(name = "my-cmd")] | ||
enum MyApp {} | ||
|
||
let version = MyApp::command().render_long_version(); | ||
|
||
assert!(version.contains("my-cmd")); | ||
} |
Oops, something went wrong.