mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
test(cksum): Add sha3 tests
This commit is contained in:
@@ -433,6 +433,146 @@ fn test_check_untagged_sha2_multiple_files() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sha3_wrong_length() {
|
||||
for l in [0, 13, 819_111_123] {
|
||||
new_ucmd!()
|
||||
.arg("--algorithm=sha3")
|
||||
.arg(format!("--length={l}"))
|
||||
.arg("lorem_ipsum.txt")
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains(format!("invalid length: '{l}'"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sha3_single_file() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--algorithm=sha3")
|
||||
.arg(format!("--length={l}"))
|
||||
.arg("lorem_ipsum.txt")
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("sha3_{l}_single_file.expected"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sha3_multiple_files() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--algorithm=sha3")
|
||||
.arg(format!("--length={l}"))
|
||||
.arg("lorem_ipsum.txt")
|
||||
.arg("alice_in_wonderland.txt")
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("sha3_{l}_multiple_files.expected"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sha3_stdin() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--algorithm=sha3")
|
||||
.arg(format!("--length={l}"))
|
||||
.pipe_in_fixture("lorem_ipsum.txt")
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("sha3_{l}_stdin.expected"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_untagged_sha3_single_file() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--untagged")
|
||||
.arg("--algorithm=sha3")
|
||||
.arg(format!("--length={l}"))
|
||||
.arg("lorem_ipsum.txt")
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("untagged/sha3_{l}_single_file.expected"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_untagged_sha3_multiple_files() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--untagged")
|
||||
.arg("--algorithm=sha3")
|
||||
.arg(format!("--length={l}"))
|
||||
.arg("lorem_ipsum.txt")
|
||||
.arg("alice_in_wonderland.txt")
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("untagged/sha3_{l}_multiple_files.expected"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_untagged_sha3_stdin() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--untagged")
|
||||
.arg("--algorithm=sha3")
|
||||
.arg(format!("--length={l}"))
|
||||
.pipe_in_fixture("lorem_ipsum.txt")
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("untagged/sha3_{l}_stdin.expected"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_tagged_sha3_single_file() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--check")
|
||||
.arg(format!("sha3_{l}_single_file.expected"))
|
||||
.succeeds()
|
||||
.stdout_is("lorem_ipsum.txt: OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_tagged_sha3_multiple_files() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--check")
|
||||
.arg(format!("sha3_{l}_multiple_files.expected"))
|
||||
.succeeds()
|
||||
.stdout_contains("lorem_ipsum.txt: OK\n")
|
||||
.stdout_contains("alice_in_wonderland.txt: OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
// When checking sha3 in untagged mode, the length is automatically deduced
|
||||
// from the length of the digest.
|
||||
#[test]
|
||||
fn test_check_untagged_sha3_single_file() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--check")
|
||||
.arg("--algorithm=sha3")
|
||||
.arg(format!("untagged/sha3_{l}_single_file.expected"))
|
||||
.succeeds()
|
||||
.stdout_is("lorem_ipsum.txt: OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_untagged_sha3_multiple_files() {
|
||||
for l in SHA_LENGTHS {
|
||||
new_ucmd!()
|
||||
.arg("--check")
|
||||
.arg("--algorithm=sha3")
|
||||
.arg(format!("untagged/sha3_{l}_multiple_files.expected"))
|
||||
.succeeds()
|
||||
.stdout_contains("lorem_ipsum.txt: OK\n")
|
||||
.stdout_contains("alice_in_wonderland.txt: OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_algo() {
|
||||
for algo in ["bsd", "sysv", "crc", "crc32b"] {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
SHA3-224 (lorem_ipsum.txt) = 00cf719da146d5f51f8969cb518aa2cb89dae71e0aad979b30398f13
|
||||
SHA3-224 (alice_in_wonderland.txt) = 33882bd6f47b47648950b4d6c606240c257eeae73e67b96610fd092c
|
||||
@@ -0,0 +1 @@
|
||||
SHA3-224 (lorem_ipsum.txt) = 00cf719da146d5f51f8969cb518aa2cb89dae71e0aad979b30398f13
|
||||
@@ -0,0 +1 @@
|
||||
SHA3-224 (-) = 00cf719da146d5f51f8969cb518aa2cb89dae71e0aad979b30398f13
|
||||
@@ -0,0 +1,2 @@
|
||||
SHA3-256 (lorem_ipsum.txt) = c9b081db1c20bdb4d8f376f45b3fb412b48c75932451d13dd79bea61e7bddbe4
|
||||
SHA3-256 (alice_in_wonderland.txt) = 507e920028b617afd342fdd0da3096237d34e33e2490c38a743bf628124803ce
|
||||
@@ -0,0 +1 @@
|
||||
SHA3-256 (lorem_ipsum.txt) = c9b081db1c20bdb4d8f376f45b3fb412b48c75932451d13dd79bea61e7bddbe4
|
||||
@@ -0,0 +1 @@
|
||||
SHA3-256 (-) = c9b081db1c20bdb4d8f376f45b3fb412b48c75932451d13dd79bea61e7bddbe4
|
||||
@@ -0,0 +1,2 @@
|
||||
SHA3-384 (lorem_ipsum.txt) = 12e0dc8c08c0f84c5facbe95ece4e0b568b3b9fbe7dbd1a6751a118c2997aa70a78123cb3d6858dc31d353fc6b874bbe
|
||||
SHA3-384 (alice_in_wonderland.txt) = d999e51e60b98da41060c287f71592517554addc14b9d27cac3935b8b312fb1e3ffad2730a9cfe855cf0fdcbce6990c6
|
||||
@@ -0,0 +1 @@
|
||||
SHA3-384 (lorem_ipsum.txt) = 12e0dc8c08c0f84c5facbe95ece4e0b568b3b9fbe7dbd1a6751a118c2997aa70a78123cb3d6858dc31d353fc6b874bbe
|
||||
@@ -0,0 +1 @@
|
||||
SHA3-384 (-) = 12e0dc8c08c0f84c5facbe95ece4e0b568b3b9fbe7dbd1a6751a118c2997aa70a78123cb3d6858dc31d353fc6b874bbe
|
||||
@@ -0,0 +1,2 @@
|
||||
SHA3-512 (lorem_ipsum.txt) = 77f7bb7e1827d7735dd1fd8bc4f4fa3ae1168a1529118c74b18f9abe69a8aecfb60fff0ecec17d2860af90e257e4fbd90048978c47fdda94f56b2ffa1d06448f
|
||||
SHA3-512 (alice_in_wonderland.txt) = 029486dea9b2bc8a2c90d852982c3a5297e626ed31a956443c6cc4794874bf4fdca76006bacc407bc101c09f85ecb3cea468c17bdfe3ad0ccff03edd786e07a8
|
||||
@@ -0,0 +1 @@
|
||||
SHA3-512 (lorem_ipsum.txt) = 77f7bb7e1827d7735dd1fd8bc4f4fa3ae1168a1529118c74b18f9abe69a8aecfb60fff0ecec17d2860af90e257e4fbd90048978c47fdda94f56b2ffa1d06448f
|
||||
@@ -0,0 +1 @@
|
||||
SHA3-512 (-) = 77f7bb7e1827d7735dd1fd8bc4f4fa3ae1168a1529118c74b18f9abe69a8aecfb60fff0ecec17d2860af90e257e4fbd90048978c47fdda94f56b2ffa1d06448f
|
||||
@@ -0,0 +1,2 @@
|
||||
00cf719da146d5f51f8969cb518aa2cb89dae71e0aad979b30398f13 lorem_ipsum.txt
|
||||
33882bd6f47b47648950b4d6c606240c257eeae73e67b96610fd092c alice_in_wonderland.txt
|
||||
@@ -0,0 +1 @@
|
||||
00cf719da146d5f51f8969cb518aa2cb89dae71e0aad979b30398f13 lorem_ipsum.txt
|
||||
@@ -0,0 +1 @@
|
||||
00cf719da146d5f51f8969cb518aa2cb89dae71e0aad979b30398f13 -
|
||||
@@ -0,0 +1,2 @@
|
||||
c9b081db1c20bdb4d8f376f45b3fb412b48c75932451d13dd79bea61e7bddbe4 lorem_ipsum.txt
|
||||
507e920028b617afd342fdd0da3096237d34e33e2490c38a743bf628124803ce alice_in_wonderland.txt
|
||||
@@ -0,0 +1 @@
|
||||
c9b081db1c20bdb4d8f376f45b3fb412b48c75932451d13dd79bea61e7bddbe4 lorem_ipsum.txt
|
||||
@@ -0,0 +1 @@
|
||||
c9b081db1c20bdb4d8f376f45b3fb412b48c75932451d13dd79bea61e7bddbe4 -
|
||||
@@ -0,0 +1,2 @@
|
||||
12e0dc8c08c0f84c5facbe95ece4e0b568b3b9fbe7dbd1a6751a118c2997aa70a78123cb3d6858dc31d353fc6b874bbe lorem_ipsum.txt
|
||||
d999e51e60b98da41060c287f71592517554addc14b9d27cac3935b8b312fb1e3ffad2730a9cfe855cf0fdcbce6990c6 alice_in_wonderland.txt
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user