From 47894a3f26d0c2fb1c850dde425a815950d6810f Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Mon, 13 May 2024 13:51:46 +0200 Subject: [PATCH] test: numf_parser test for all types that should be supported by the generic #13 --- tests/format.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/format.rs b/tests/format.rs index 476bd4a..d47ade7 100644 --- a/tests/format.rs +++ b/tests/format.rs @@ -201,32 +201,41 @@ fn set_format_checker() { #[test] fn parser_dec() { - assert_eq!(numf_parser("1337").unwrap(), 1337); - assert_eq!(numf_parser("0d1337").unwrap(), 1337); + assert_eq!(numf_parser::("1337").unwrap(), 1337); + assert_eq!(numf_parser::("0d1337").unwrap(), 1337); } #[test] fn parser_bin() { - assert_eq!(numf_parser("0b11001").unwrap(), 0b11001); - assert_eq!(numf_parser("0b11001").unwrap(), 0b11001); + assert_eq!(numf_parser::("0b11001").unwrap(), 0b11001); + assert_eq!(numf_parser::("0b11001").unwrap(), 0b11001); } #[test] fn parser_hex() { - assert_eq!(numf_parser("0xdeadbeef").unwrap(), 0xdeadbeef); + assert_eq!(numf_parser::("0xdeadbeef").unwrap(), 0xdeadbeef); } #[test] fn parser_oct() { - assert_eq!(numf_parser("0o771171").unwrap(), 0o771171); + assert_eq!(numf_parser::("0o771171").unwrap(), 0o771171); } #[test] fn parser_b64() { - assert_eq!(numf_parser("0sQUFCQg==").unwrap(), 0x41414242); + assert_eq!(numf_parser::("0sQUFCQg==").unwrap(), 0x41414242); } #[test] fn parser_b32() { - assert_eq!(numf_parser("IFAUEQQ=").unwrap(), 0x41414242); + assert_eq!(numf_parser::("IFAUEQQ=").unwrap(), 0x41414242); +} + +#[test] +fn parser_generics() { + assert_eq!(numf_parser::("55").unwrap(), 55); + assert_eq!(numf_parser::("55").unwrap(), 55); + assert_eq!(numf_parser::("55").unwrap(), 55); + assert_eq!(numf_parser::("55").unwrap(), 55); + assert_eq!(numf_parser::("55").unwrap(), 55); }