Skip to content

Commit cf7df57

Browse files
committed
test(cksum): Test for cksum -a blake3
1 parent dde0a40 commit cf7df57

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

tests/by-util/test_cksum.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,3 +3287,62 @@ fn test_check_shake256_no_length() {
32873287
.fails()
32883288
.stderr_only("cksum: 'standard input': no properly formatted checksum lines found\n");
32893289
}
3290+
3291+
#[rstest]
3292+
#[case(
3293+
b"foo",
3294+
"04e0bb39f30b1a3feb89f536c93be15055482df748674b00d26e5a75777702e9"
3295+
)]
3296+
fn test_blake3b_no_length(#[case] input: &[u8], #[case] expected: &str) {
3297+
new_ucmd!()
3298+
.arg("-a")
3299+
.arg("blake3")
3300+
.pipe_in(input)
3301+
.succeeds()
3302+
.stdout_only(format!("BLAKE3-32 (-) = {expected}\n"));
3303+
}
3304+
3305+
#[rstest]
3306+
#[case(
3307+
b"foo",
3308+
"04e0bb39f30b1a3feb89f536c93be15055482df748674b00d26e5a75777702e9",
3309+
0
3310+
)]
3311+
#[case(
3312+
b"foo",
3313+
"04e0bb39f30b1a3feb89f536c93be15055482df748674b00d26e5a75777702e9",
3314+
32
3315+
)]
3316+
#[case(
3317+
b"foo",
3318+
"04e0bb39f30b1a3feb89f536c93be15055482df748674b00d26e5a75777702e9791074b7511b59d31c71c62f5a745689fa6c",
3319+
50
3320+
)]
3321+
#[case(b"foo", "04e0bb39f3", 5)]
3322+
#[case(b"foo", "04e0", 2)]
3323+
#[case(b"foo", "04", 1)]
3324+
fn test_blake3b(#[case] input: &[u8], #[case] expected: &str, #[case] length: usize) {
3325+
new_ucmd!()
3326+
.arg("-a")
3327+
.arg("blake3")
3328+
.args(&["-l", &length.to_string()])
3329+
.pipe_in(input)
3330+
.succeeds()
3331+
.stdout_only(format!(
3332+
"BLAKE3-{} (-) = {expected}\n",
3333+
match length {
3334+
0 => "32".to_string(),
3335+
i => i.to_string(),
3336+
}
3337+
));
3338+
3339+
// with --untagged
3340+
new_ucmd!()
3341+
.arg("-a")
3342+
.arg("blake3")
3343+
.arg("--untagged")
3344+
.args(&["-l", &length.to_string()])
3345+
.pipe_in(input)
3346+
.succeeds()
3347+
.stdout_only(format!("{expected} -\n"));
3348+
}

0 commit comments

Comments
 (0)