Skip to content

Commit 00d9070

Browse files
committed
test(hashsum): Improve tests for checking length validation errors for BLAKE2b
1 parent 7abdd91 commit 00d9070

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tests/by-util/test_hashsum.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6+
use rstest::rstest;
7+
68
use uutests::new_ucmd;
79
use uutests::util::TestScenario;
810
use uutests::util_name;
@@ -250,21 +252,30 @@ fn test_invalid_b2sum_length_option_not_multiple_of_8() {
250252
.ccmd("b2sum")
251253
.arg("--length=9")
252254
.arg(at.subdir.join("testf"))
253-
.fails_with_code(1);
255+
.fails_with_code(1)
256+
.stderr_contains("b2sum: invalid length: '9'")
257+
.stderr_contains("b2sum: length is not a multiple of 8");
254258
}
255259

256-
#[test]
257-
fn test_invalid_b2sum_length_option_too_large() {
260+
#[rstest]
261+
#[case("513")]
262+
#[case("1024")]
263+
#[case("18446744073709552000")]
264+
fn test_invalid_b2sum_length_option_too_large(#[case] len: &str) {
258265
let scene = TestScenario::new(util_name!());
259266
let at = &scene.fixtures;
260267

261268
at.write("testf", "foobar\n");
262269

263270
scene
264271
.ccmd("b2sum")
265-
.arg("--length=513")
272+
.arg("--length")
273+
.arg(len)
266274
.arg(at.subdir.join("testf"))
267-
.fails_with_code(1);
275+
.fails_with_code(1)
276+
.no_stdout()
277+
.stderr_contains(format!("b2sum: invalid length: '{len}'"))
278+
.stderr_contains("b2sum: maximum digest length for 'BLAKE2b' is 512 bits");
268279
}
269280

270281
#[test]

0 commit comments

Comments
 (0)