@@ -46,6 +46,13 @@ static COMPLEX_SEQUENCE: &TestedSequence = &TestedSequence {
4646 sequence : "9-,6-7,-2,4" ,
4747} ;
4848
49+ #[ test]
50+ fn test_no_args ( ) {
51+ new_ucmd ! ( ) . fails ( ) . stderr_is (
52+ "cut: invalid usage: expects one of --fields (-f), --chars (-c) or --bytes (-b)\n " ,
53+ ) ;
54+ }
55+
4956#[ test]
5057fn test_invalid_arg ( ) {
5158 new_ucmd ! ( ) . arg ( "--definitely-invalid" ) . fails ( ) . code_is ( 1 ) ;
@@ -249,25 +256,29 @@ fn test_no_such_file() {
249256}
250257
251258#[ test]
252- fn test_equal_as_delimiter1 ( ) {
253- new_ucmd ! ( )
254- . args ( & [ "-f" , "2" , "-d=" ] )
255- . pipe_in ( "--dir=./out/lib" )
256- . succeeds ( )
257- . stdout_only ( "./out/lib\n " ) ;
259+ fn test_equal_as_delimiter ( ) {
260+ for arg in [ "-d=" , "--delimiter==" ] {
261+ new_ucmd ! ( )
262+ . args ( & [ "-f2" , arg] )
263+ . pipe_in ( "--dir=./out/lib" )
264+ . succeeds ( )
265+ . stdout_only ( "./out/lib\n " ) ;
266+ }
258267}
259268
260269#[ test]
261- fn test_equal_as_delimiter2 ( ) {
262- new_ucmd ! ( )
263- . args ( & [ "-f2" , "--delimiter=" ] )
264- . pipe_in ( "a=b\n " )
265- . succeeds ( )
266- . stdout_only ( "a=b\n " ) ;
270+ fn test_empty_string_as_delimiter ( ) {
271+ for arg in [ "-d''" , "--delimiter=" , "--delimiter=''" ] {
272+ new_ucmd ! ( )
273+ . args ( & [ "-f2" , arg] )
274+ . pipe_in ( "a\0 b\n " )
275+ . succeeds ( )
276+ . stdout_only ( "b\n " ) ;
277+ }
267278}
268279
269280#[ test]
270- fn test_equal_as_delimiter3 ( ) {
281+ fn test_empty_string_as_delimiter_with_output_delimiter ( ) {
271282 new_ucmd ! ( )
272283 . args ( & [ "-f" , "1,2" , "-d" , "''" , "--output-delimiter=Z" ] )
273284 . pipe_in ( "ab\0 cd\n " )
@@ -276,24 +287,23 @@ fn test_equal_as_delimiter3() {
276287}
277288
278289#[ test]
279- fn test_multiple ( ) {
280- let result = new_ucmd ! ( )
281- . args ( & [ "-f2" , "-d:" , "-d=" ] )
282- . pipe_in ( "a=b\n " )
283- . succeeds ( ) ;
284- assert_eq ! ( result. stdout_str( ) , "b\n " ) ;
285- assert_eq ! ( result. stderr_str( ) , "" ) ;
286- }
287-
288- #[ test]
289- fn test_newline_delimited ( ) {
290+ fn test_newline_as_delimiter ( ) {
290291 new_ucmd ! ( )
291292 . args ( & [ "-f" , "1" , "-d" , "\n " ] )
292293 . pipe_in ( "a:1\n b:" )
293294 . succeeds ( )
294295 . stdout_only_bytes ( "a:1\n b:\n " ) ;
295296}
296297
298+ #[ test]
299+ fn test_multiple_delimiters ( ) {
300+ new_ucmd ! ( )
301+ . args ( & [ "-f2" , "-d:" , "-d=" ] )
302+ . pipe_in ( "a=b\n " )
303+ . succeeds ( )
304+ . stdout_only ( "b\n " ) ;
305+ }
306+
297307#[ test]
298308fn test_multiple_mode_args ( ) {
299309 for args in [
@@ -312,13 +322,6 @@ fn test_multiple_mode_args() {
312322 }
313323}
314324
315- #[ test]
316- fn test_no_argument ( ) {
317- new_ucmd ! ( ) . fails ( ) . stderr_is (
318- "cut: invalid usage: expects one of --fields (-f), --chars (-c) or --bytes (-b)\n " ,
319- ) ;
320- }
321-
322325#[ test]
323326#[ cfg( unix) ]
324327fn test_8bit_non_utf8_delimiter ( ) {
0 commit comments