@@ -2458,6 +2458,71 @@ mod gnu_cksum_c {
24582458 scene
24592459 }
24602460
2461+ fn make_scene_with_comment ( ) -> TestScenario {
2462+ let scene = make_scene ( ) ;
2463+
2464+ scene
2465+ . fixtures
2466+ . append ( "CHECKSUMS" , "# Very important comment\n " ) ;
2467+
2468+ scene
2469+ }
2470+
2471+ fn make_scene_with_invalid_line ( ) -> TestScenario {
2472+ let scene = make_scene_with_comment ( ) ;
2473+
2474+ scene. fixtures . append ( "CHECKSUMS" , "invalid_line\n " ) ;
2475+
2476+ scene
2477+ }
2478+
2479+ #[ test]
2480+ fn test_tagged_invalid_length ( ) {
2481+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2482+
2483+ at. write (
2484+ "sha2-bad-length.sum" ,
2485+ "SHA2-128 (/dev/null) = 38b060a751ac96384cd9327eb1b1e36a" ,
2486+ ) ;
2487+
2488+ ucmd. arg ( "--check" )
2489+ . arg ( "sha2-bad-length.sum" )
2490+ . fails ( )
2491+ . stderr_contains ( "sha2-bad-length.sum: no properly formatted checksum lines found" ) ;
2492+ }
2493+
2494+ #[ test]
2495+ #[ cfg_attr( not( unix) , ignore = "/dev/null is only available on UNIX" ) ]
2496+ fn test_untagged_base64_matching_tag ( ) {
2497+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2498+
2499+ at. write ( "tag-prefix.sum" , "SHA1+++++++++++++++++++++++= /dev/null" ) ;
2500+
2501+ ucmd. arg ( "--check" )
2502+ . arg ( "-a" )
2503+ . arg ( "sha1" )
2504+ . arg ( "tag-prefix.sum" )
2505+ . fails ( )
2506+ . stderr_contains ( "WARNING: 1 computed checksum did NOT match" ) ;
2507+ }
2508+
2509+ #[ test]
2510+ #[ cfg_attr( windows, ignore = "Awkward filename is not supported on windows" ) ]
2511+ fn test_awkward_filename ( ) {
2512+ let ts = TestScenario :: new ( util_name ! ( ) ) ;
2513+ let at = & ts. fixtures ;
2514+
2515+ let awkward_file = "abc (f) = abc" ;
2516+
2517+ at. touch ( awkward_file) ;
2518+
2519+ let result = ts. ucmd ( ) . arg ( "-a" ) . arg ( "sha1" ) . arg ( awkward_file) . succeeds ( ) ;
2520+
2521+ at. write_bytes ( "tag-awkward.sum" , result. stdout ( ) ) ;
2522+
2523+ ts. ucmd ( ) . arg ( "-c" ) . arg ( "tag-awkward.sum" ) . succeeds ( ) ;
2524+ }
2525+
24612526 #[ test]
24622527 #[ ignore = "todo" ]
24632528 fn test_signed_checksums ( ) {
@@ -2509,16 +2574,6 @@ mod gnu_cksum_c {
25092574 . no_output ( ) ;
25102575 }
25112576
2512- fn make_scene_with_comment ( ) -> TestScenario {
2513- let scene = make_scene ( ) ;
2514-
2515- scene
2516- . fixtures
2517- . append ( "CHECKSUMS" , "# Very important comment\n " ) ;
2518-
2519- scene
2520- }
2521-
25222577 #[ test]
25232578 fn test_status_with_comment ( ) {
25242579 let scene = make_scene_with_comment ( ) ;
@@ -2532,14 +2587,6 @@ mod gnu_cksum_c {
25322587 . no_output ( ) ;
25332588 }
25342589
2535- fn make_scene_with_invalid_line ( ) -> TestScenario {
2536- let scene = make_scene_with_comment ( ) ;
2537-
2538- scene. fixtures . append ( "CHECKSUMS" , "invalid_line\n " ) ;
2539-
2540- scene
2541- }
2542-
25432590 #[ test]
25442591 fn test_check_strict ( ) {
25452592 let scene = make_scene_with_invalid_line ( ) ;
0 commit comments