test: numf_parser test for all types that should be supported by the generic #13
cargo devel CI / cargo CI (push) Failing after 1m9s Details

This commit is contained in:
Christoph J. Scherr 2024-05-13 13:51:46 +02:00
parent 6649470ff7
commit 47894a3f26
1 changed files with 17 additions and 8 deletions

View File

@ -201,32 +201,41 @@ fn set_format_checker() {
#[test] #[test]
fn parser_dec() { fn parser_dec() {
assert_eq!(numf_parser("1337").unwrap(), 1337); assert_eq!(numf_parser::<u32>("1337").unwrap(), 1337);
assert_eq!(numf_parser("0d1337").unwrap(), 1337); assert_eq!(numf_parser::<u32>("0d1337").unwrap(), 1337);
} }
#[test] #[test]
fn parser_bin() { fn parser_bin() {
assert_eq!(numf_parser("0b11001").unwrap(), 0b11001); assert_eq!(numf_parser::<u32>("0b11001").unwrap(), 0b11001);
assert_eq!(numf_parser("0b11001").unwrap(), 0b11001); assert_eq!(numf_parser::<u32>("0b11001").unwrap(), 0b11001);
} }
#[test] #[test]
fn parser_hex() { fn parser_hex() {
assert_eq!(numf_parser("0xdeadbeef").unwrap(), 0xdeadbeef); assert_eq!(numf_parser::<u32>("0xdeadbeef").unwrap(), 0xdeadbeef);
} }
#[test] #[test]
fn parser_oct() { fn parser_oct() {
assert_eq!(numf_parser("0o771171").unwrap(), 0o771171); assert_eq!(numf_parser::<u32>("0o771171").unwrap(), 0o771171);
} }
#[test] #[test]
fn parser_b64() { fn parser_b64() {
assert_eq!(numf_parser("0sQUFCQg==").unwrap(), 0x41414242); assert_eq!(numf_parser::<u32>("0sQUFCQg==").unwrap(), 0x41414242);
} }
#[test] #[test]
fn parser_b32() { fn parser_b32() {
assert_eq!(numf_parser("IFAUEQQ=").unwrap(), 0x41414242); assert_eq!(numf_parser::<u32>("IFAUEQQ=").unwrap(), 0x41414242);
}
#[test]
fn parser_generics() {
assert_eq!(numf_parser::<u8>("55").unwrap(), 55);
assert_eq!(numf_parser::<u16>("55").unwrap(), 55);
assert_eq!(numf_parser::<u32>("55").unwrap(), 55);
assert_eq!(numf_parser::<u64>("55").unwrap(), 55);
assert_eq!(numf_parser::<u128>("55").unwrap(), 55);
} }