Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/cksum/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cksum-after-help = DIGEST determines the digest algorithm and default output for
- md5: (equivalent to md5sum)
- sha1: (equivalent to sha1sum)
- sha2: (equivalent to sha{"{224,256,384,512}"}sum)
- sha3: (only available through cksum)
- sha3: (requires --length: 224, 256, 384, or 512)
- blake2b: (equivalent to b2sum)
- sm3: (only available through cksum)

Expand Down
2 changes: 1 addition & 1 deletion src/uu/cksum/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cksum-after-help = DIGEST détermine l'algorithme de condensé et le format de s
- md5 : (équivalent à md5sum)
- sha1 : (équivalent à sha1sum)
- sha2: (équivalent à sha{"{224,256,384,512}"}sum)
- sha3 : (disponible uniquement via cksum)
- sha3 : (nécessite --length : 224, 256, 384, ou 512)
- blake2b : (équivalent à b2sum)
- sm3 : (disponible uniquement via cksum)

Expand Down
91 changes: 91 additions & 0 deletions tests/by-util/test_cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2859,6 +2859,97 @@ mod gnu_cksum_c {
}
}

#[test]
fn test_sha3_with_length() {
// Test SHA3-224
new_ucmd!()
.arg("-a")
.arg("sha3")
.arg("--length")
.arg("224")
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_contains("SHA3-224 (lorem_ipsum.txt) = ");

// Test SHA3-256
new_ucmd!()
.arg("-a")
.arg("sha3")
.arg("--length")
.arg("256")
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_contains("SHA3-256 (lorem_ipsum.txt) = ");

// Test SHA3-384
new_ucmd!()
.arg("-a")
.arg("sha3")
.arg("--length")
.arg("384")
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_contains("SHA3-384 (lorem_ipsum.txt) = ");

// Test SHA3-512
new_ucmd!()
.arg("-a")
.arg("sha3")
.arg("--length")
.arg("512")
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_contains("SHA3-512 (lorem_ipsum.txt) = ");
}

#[test]
fn test_sha3_invalid_length() {
// Test SHA3 with invalid length (not 224, 256, 384, or 512)
new_ucmd!()
.arg("-a")
.arg("sha3")
.arg("--length")
.arg("128")
.arg("lorem_ipsum.txt")
.fails()
.stderr_contains("digest length for 'SHA3' must be 224, 256, 384, or 512");

// Test SHA3 without length
new_ucmd!()
.arg("-a")
.arg("sha3")
.arg("lorem_ipsum.txt")
.fails()
.stderr_contains("--algorithm=sha3 requires specifying --length 224, 256, 384, or 512");
}

#[test]
fn test_sha3_base64_output() {
// Test SHA3 with base64 output format
new_ucmd!()
.arg("--base64")
.arg("-a")
.arg("sha3")
.arg("--length")
.arg("256")
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_contains("SHA3-256 (lorem_ipsum.txt) = ");
}

#[test]
fn test_sha3_untagged() {
// Test SHA3 with untagged output
new_ucmd!()
.arg("--untagged")
.arg("-a")
.arg("sha3")
.arg("--length")
.arg("256")
.arg("lorem_ipsum.txt")
.succeeds();
}

/// The tests in this module check the behavior of cksum when given different
/// checksum formats and algorithms in the same file, while specifying an
/// algorithm on CLI or not.
Expand Down
Loading