test: Add unit tests for hex_u32
Test the current behaviour of `hex_u32` - verifies that we handle parsing strings with and without a prefix.
This commit is contained in:
parent
499f36f972
commit
dca054c680
|
@ -182,3 +182,22 @@ macro_rules! impl_parse_str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_u32_from_hex_prefixed() {
|
||||||
|
let want = 171;
|
||||||
|
let got = hex_u32("0xab").expect("failed to parse prefixed hex");
|
||||||
|
assert_eq!(got, want);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_u32_from_hex_no_prefix() {
|
||||||
|
let want = 171;
|
||||||
|
let got = hex_u32("ab").expect("failed to parse non-prefixed hex");
|
||||||
|
assert_eq!(got, want);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue