-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5778a0e
commit ad7fa88
Showing
8 changed files
with
79 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use deku::prelude::*; | ||
use std::io::Cursor; | ||
|
||
// Invalid alignment assumptions when converting | ||
// BitSlice to type | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use deku::prelude::*; | ||
use hexlit::hex; | ||
use rstest::*; | ||
|
||
use std::convert::TryFrom; | ||
Check warning on line 5 in tests/test_seek.rs GitHub Actions / Test Suite
|
||
|
||
#[derive(DekuRead, Debug, PartialEq, Eq)] | ||
pub struct Test { | ||
// how many following bytes to skip | ||
skip_u8: u8, | ||
#[deku(seek_from_current = "*skip_u8")] | ||
byte: u8, | ||
} | ||
|
||
#[rstest(input, expected, | ||
case(&hex!("010020"), Test{ skip_u8: 1, byte: 0x20 }), | ||
)] | ||
fn test_seek_from_current(input: &[u8], expected: Test) { | ||
let input = input.to_vec(); | ||
// TODO: fix, "too much data" | ||
//let ret_read = Test::try_from(input.as_slice()).unwrap(); | ||
|
||
let mut cursor = std::io::Cursor::new(input); | ||
let (_, ret_read) = Test::from_reader((&mut cursor, 0)).unwrap(); | ||
|
||
assert_eq!(ret_read, expected); | ||
} |