Skip to content

Commit

Permalink
tests: add wrap_help test with significant whitepace
Browse files Browse the repository at this point in the history
This adds a test for the issue clap-rs#617 about keeping whitespace intact in
manually aligned text.
  • Loading branch information
mgeisler committed Feb 8, 2017
1 parent 92919f5 commit 00e3b03
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ FLAGS:
(Defaults to something)
-V, --version Prints version information";

static WRAPPING_NEWLINE_CHARS: &'static str = "ctest 0.1
USAGE:
ctest [mode]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
ARGS:
<mode> x, max, maximum 20 characters, contains
symbols.
l, long Copy-friendly,
14 characters, contains symbols.
m, med, medium Copy-friendly, 8
characters, contains symbols.";

static ISSUE_688: &'static str = "ctest 0.1
Expand Down Expand Up @@ -429,6 +445,19 @@ fn final_word_wrapping() {
assert!(test::compare_output(app, "ctest --help", FINAL_WORD_WRAPPING, false));
}

#[test]
#[should_panic]
fn wrapping_newline_chars() {
let app = App::new("ctest")
.version("0.1")
.set_term_width(60)
.arg(Arg::with_name("mode")
.help("x, max, maximum 20 characters, contains symbols.{n}\
l, long Copy-friendly, 14 characters, contains symbols.{n}\
m, med, medium Copy-friendly, 8 characters, contains symbols.{n}"));
assert!(test::compare_output(app, "ctest --help", WRAPPING_NEWLINE_CHARS, false));
}

#[test]
fn old_newline_chars() {
let app = App::new("ctest")
Expand Down

0 comments on commit 00e3b03

Please sign in to comment.