Skip to content

Commit b359128

Browse files
author
David James
committed
test: add failing test corresponding with #15
``` thread 'tests::test_validate::test_validate_len_9' panicked at src/validate.rs:148:33: attempt to subtract with overflow ```
1 parent 593c26e commit b359128

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/tests/test_validate.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@ use super::helpers as h;
22
use super::helpers::Cursor;
33
use crate::{Config, CrcStore};
44

5+
#[test]
6+
fn test_validate_len_9() {
7+
let len = 9;
8+
let mut rng = rand::thread_rng();
9+
for seg_len in [16, 32, 64, 128, 256, 512] {
10+
for buf_len in [8, 16, 32, 64, 128, 256, 512] {
11+
let config = Config {
12+
seg_len,
13+
buf_len,
14+
validate_on_read: false,
15+
};
16+
let data = h::valid_data(&mut rng, seg_len, len);
17+
let cursor = Cursor::new(data);
18+
let mut store = CrcStore::new(config, cursor).unwrap();
19+
let result = store.validate();
20+
assert!(result.is_ok());
21+
}
22+
}
23+
}
24+
525
#[test]
626
fn test_validate_len_64() {
727
let len = 64;

0 commit comments

Comments
 (0)