xpat
This commit is contained in:
@@ -10,7 +10,7 @@ macros = ["sub_macros"]
|
||||
libm = ["sub_libm"]
|
||||
pe = ["sub_pe"]
|
||||
|
||||
|
||||
xpat = ["core", "sub_xpat", "macros"]
|
||||
winuser = ["sub_winu", "pe", "sub_pe/windows"]
|
||||
|
||||
[dependencies]
|
||||
@@ -18,4 +18,5 @@ sub_core = { workspace = true, optional = true }
|
||||
sub_libm = { workspace = true, optional = true}
|
||||
sub_pe = { workspace = true, optional = true }
|
||||
sub_winu = { workspace = true, optional = true }
|
||||
sub_macros = { workspace = true, optional = true }
|
||||
sub_macros = { workspace = true, optional = true }
|
||||
sub_xpat = { workspace = true, optional = true }
|
||||
@@ -18,6 +18,7 @@ import!(sub_core, core, "core");
|
||||
import!(sub_libm, libm, "libm");
|
||||
import!(sub_pe, pe, "pe");
|
||||
import!(sub_winu, win, "winuser");
|
||||
import!(sub_xpat, xpat, "xpat");
|
||||
|
||||
/// the macro crate is a proc macro, so it is a bit different.
|
||||
#[cfg(feature = "macros")]
|
||||
|
||||
17
x/tests/test_xpat.rs
Normal file
17
x/tests/test_xpat.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
pub fn test_pattern() {
|
||||
|
||||
let pattern = x::pattern!("E8 [0-4] BB ");
|
||||
let buffer: &[u8] = &[ 0xAA, 0xE8, 0xBB, 0xE8, 0x00, 0xBB, ];
|
||||
|
||||
let mut scanner = x::Scanner::new(buffer, pattern, ..);
|
||||
let mut saves = [0usize;8];
|
||||
|
||||
assert!(scanner.next(&mut saves));
|
||||
assert_eq!(saves[0], 1);
|
||||
assert!(scanner.next(&mut saves));
|
||||
assert_eq!(saves[0], 3);
|
||||
}
|
||||
Reference in New Issue
Block a user