@@ -3,7 +3,7 @@ extern crate regex;
3
3
4
4
include ! ( "../clap-test.rs" ) ;
5
5
6
- use clap:: { App , SubCommand , ErrorKind } ;
6
+ use clap:: { App , SubCommand , ErrorKind , Arg } ;
7
7
8
8
static HELP : & ' static str = "clap-test v1.4.8
9
9
@@ -81,6 +81,45 @@ FLAGS:
81
81
OPTIONS:
82
82
-o, --option <scoption>... tests options" ;
83
83
84
+ static ISSUE_626_CUTOFF : & ' static str = "ctest 0.1
85
+
86
+ USAGE:
87
+ ctest [OPTIONS]
88
+
89
+ FLAGS:
90
+ -h, --help Prints help information
91
+ -V, --version Prints version information
92
+
93
+ OPTIONS:
94
+ -c, --cafe <FILE> A coffeehouse, coffee shop, or café is an
95
+ establishment which primarily serves hot
96
+ coffee, related coffee beverages (e.g., café
97
+ latte, cappuccino, espresso), tea, and other
98
+ hot beverages. Some coffeehouses also serve cold
99
+ beverages such as iced coffee and iced tea. Many
100
+ cafés also serve some type of food, such as light
101
+ snacks, muffins, or pastries." ;
102
+
103
+ static ISSUE_626_PANIC : & ' static str = "ctest 0.1
104
+
105
+ USAGE:
106
+ ctest [OPTIONS]
107
+
108
+ FLAGS:
109
+ -h, --help Prints help information
110
+ -V, --version Prints version information
111
+
112
+ OPTIONS:
113
+ -c, --cafe <FILE> La culture du café est très
114
+ développée dans de
115
+ nombreux pays à climat chaud
116
+ d'Amérique, d'Afrique et
117
+ d'Asie, dans des plantations qui
118
+ sont cultivées pour les marchés
119
+ d'exportation. Le café est souvent
120
+ une contribution majeure aux
121
+ exportations des régions productrices." ;
122
+
84
123
#[ test]
85
124
fn help_short ( ) {
86
125
let m = App :: new ( "test" )
@@ -207,3 +246,39 @@ fn complex_subcommand_help_output() {
207
246
sc. write_help ( & mut help) . ok ( ) . expect ( "failed to print help" ) ;
208
247
assert_eq ! ( & * String :: from_utf8( help) . unwrap( ) , SC_HELP ) ;
209
248
}
249
+
250
+
251
+ #[ test]
252
+ fn issue_626_unicode_cutoff ( ) {
253
+ let app = App :: new ( "ctest" )
254
+ . version ( "0.1" )
255
+ . set_term_width ( 70 )
256
+ . arg ( Arg :: with_name ( "cafe" )
257
+ . short ( "c" )
258
+ . long ( "cafe" )
259
+ . value_name ( "FILE" )
260
+ . help ( "A coffeehouse, coffee shop, or café is an establishment \
261
+ which primarily serves hot coffee, related coffee beverages \
262
+ (e.g., café latte, cappuccino, espresso), tea, and other hot \
263
+ beverages. Some coffeehouses also serve cold beverages such as \
264
+ iced coffee and iced tea. Many cafés also serve some type of \
265
+ food, such as light snacks, muffins, or pastries.")
266
+ . takes_value ( true ) ) ;
267
+ test:: check_err_output ( app, "ctest --help" , ISSUE_626_CUTOFF , false ) ;
268
+ }
269
+
270
+ #[ test]
271
+ fn issue_626_panic ( ) {
272
+ let app = App :: new ( "ctest" )
273
+ . version ( "0.1" )
274
+ . set_term_width ( 53 )
275
+ . arg ( Arg :: with_name ( "cafe" )
276
+ . short ( "c" )
277
+ . long ( "cafe" )
278
+ . value_name ( "FILE" )
279
+ . help ( "La culture du café est très développée dans de nombreux pays à climat chaud d'Amérique, \
280
+ d'Afrique et d'Asie, dans des plantations qui sont cultivées pour les marchés d'exportation. \
281
+ Le café est souvent une contribution majeure aux exportations des régions productrices.")
282
+ . takes_value ( true ) ) ;
283
+ test:: check_err_output ( app, "ctest --help" , ISSUE_626_PANIC , false ) ;
284
+ }
0 commit comments