@@ -433,6 +433,146 @@ fn test_check_untagged_sha2_multiple_files() {
433433 }
434434}
435435
436+ #[ test]
437+ fn test_sha3_wrong_length ( ) {
438+ for l in [ 0 , 13 , 819_111_123 ] {
439+ new_ucmd ! ( )
440+ . arg ( "--algorithm=sha3" )
441+ . arg ( format ! ( "--length={l}" ) )
442+ . arg ( "lorem_ipsum.txt" )
443+ . fails_with_code ( 1 )
444+ . no_stdout ( )
445+ . stderr_contains ( format ! ( "invalid length: '{l}'" ) ) ;
446+ }
447+ }
448+
449+ #[ test]
450+ fn test_sha3_single_file ( ) {
451+ for l in SHA_LENGTHS {
452+ new_ucmd ! ( )
453+ . arg ( "--algorithm=sha3" )
454+ . arg ( format ! ( "--length={l}" ) )
455+ . arg ( "lorem_ipsum.txt" )
456+ . succeeds ( )
457+ . stdout_is_fixture ( format ! ( "sha3_{l}_single_file.expected" ) ) ;
458+ }
459+ }
460+
461+ #[ test]
462+ fn test_sha3_multiple_files ( ) {
463+ for l in SHA_LENGTHS {
464+ new_ucmd ! ( )
465+ . arg ( "--algorithm=sha3" )
466+ . arg ( format ! ( "--length={l}" ) )
467+ . arg ( "lorem_ipsum.txt" )
468+ . arg ( "alice_in_wonderland.txt" )
469+ . succeeds ( )
470+ . stdout_is_fixture ( format ! ( "sha3_{l}_multiple_files.expected" ) ) ;
471+ }
472+ }
473+
474+ #[ test]
475+ fn test_sha3_stdin ( ) {
476+ for l in SHA_LENGTHS {
477+ new_ucmd ! ( )
478+ . arg ( "--algorithm=sha3" )
479+ . arg ( format ! ( "--length={l}" ) )
480+ . pipe_in_fixture ( "lorem_ipsum.txt" )
481+ . succeeds ( )
482+ . stdout_is_fixture ( format ! ( "sha3_{l}_stdin.expected" ) ) ;
483+ }
484+ }
485+
486+ #[ test]
487+ fn test_untagged_sha3_single_file ( ) {
488+ for l in SHA_LENGTHS {
489+ new_ucmd ! ( )
490+ . arg ( "--untagged" )
491+ . arg ( "--algorithm=sha3" )
492+ . arg ( format ! ( "--length={l}" ) )
493+ . arg ( "lorem_ipsum.txt" )
494+ . succeeds ( )
495+ . stdout_is_fixture ( format ! ( "untagged/sha3_{l}_single_file.expected" ) ) ;
496+ }
497+ }
498+
499+ #[ test]
500+ fn test_untagged_sha3_multiple_files ( ) {
501+ for l in SHA_LENGTHS {
502+ new_ucmd ! ( )
503+ . arg ( "--untagged" )
504+ . arg ( "--algorithm=sha3" )
505+ . arg ( format ! ( "--length={l}" ) )
506+ . arg ( "lorem_ipsum.txt" )
507+ . arg ( "alice_in_wonderland.txt" )
508+ . succeeds ( )
509+ . stdout_is_fixture ( format ! ( "untagged/sha3_{l}_multiple_files.expected" ) ) ;
510+ }
511+ }
512+
513+ #[ test]
514+ fn test_untagged_sha3_stdin ( ) {
515+ for l in SHA_LENGTHS {
516+ new_ucmd ! ( )
517+ . arg ( "--untagged" )
518+ . arg ( "--algorithm=sha3" )
519+ . arg ( format ! ( "--length={l}" ) )
520+ . pipe_in_fixture ( "lorem_ipsum.txt" )
521+ . succeeds ( )
522+ . stdout_is_fixture ( format ! ( "untagged/sha3_{l}_stdin.expected" ) ) ;
523+ }
524+ }
525+
526+ #[ test]
527+ fn test_check_tagged_sha3_single_file ( ) {
528+ for l in SHA_LENGTHS {
529+ new_ucmd ! ( )
530+ . arg ( "--check" )
531+ . arg ( format ! ( "sha3_{l}_single_file.expected" ) )
532+ . succeeds ( )
533+ . stdout_is ( "lorem_ipsum.txt: OK\n " ) ;
534+ }
535+ }
536+
537+ #[ test]
538+ fn test_check_tagged_sha3_multiple_files ( ) {
539+ for l in SHA_LENGTHS {
540+ new_ucmd ! ( )
541+ . arg ( "--check" )
542+ . arg ( format ! ( "sha3_{l}_multiple_files.expected" ) )
543+ . succeeds ( )
544+ . stdout_contains ( "lorem_ipsum.txt: OK\n " )
545+ . stdout_contains ( "alice_in_wonderland.txt: OK\n " ) ;
546+ }
547+ }
548+
549+ // When checking sha3 in untagged mode, the length is automatically deduced
550+ // from the length of the digest.
551+ #[ test]
552+ fn test_check_untagged_sha3_single_file ( ) {
553+ for l in SHA_LENGTHS {
554+ new_ucmd ! ( )
555+ . arg ( "--check" )
556+ . arg ( "--algorithm=sha3" )
557+ . arg ( format ! ( "untagged/sha3_{l}_single_file.expected" ) )
558+ . succeeds ( )
559+ . stdout_is ( "lorem_ipsum.txt: OK\n " ) ;
560+ }
561+ }
562+
563+ #[ test]
564+ fn test_check_untagged_sha3_multiple_files ( ) {
565+ for l in SHA_LENGTHS {
566+ new_ucmd ! ( )
567+ . arg ( "--check" )
568+ . arg ( "--algorithm=sha3" )
569+ . arg ( format ! ( "untagged/sha3_{l}_multiple_files.expected" ) )
570+ . succeeds ( )
571+ . stdout_contains ( "lorem_ipsum.txt: OK\n " )
572+ . stdout_contains ( "alice_in_wonderland.txt: OK\n " ) ;
573+ }
574+ }
575+
436576#[ test]
437577fn test_check_algo ( ) {
438578 for algo in [ "bsd" , "sysv" , "crc" , "crc32b" ] {
0 commit comments