From 1262be3f0a2dd33357103ffd31404c2bf1c044f8 Mon Sep 17 00:00:00 2001 From: nujz Date: Sun, 20 Sep 2020 08:55:05 +0800 Subject: [PATCH] add unit test --- router/src/url.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/router/src/url.rs b/router/src/url.rs index 7c0fb742..6215982a 100644 --- a/router/src/url.rs +++ b/router/src/url.rs @@ -225,4 +225,19 @@ mod tests { assert!(re.match_path(&mut path)); assert_eq!(path.get("id").unwrap(), "qwe%rty"); } + + #[test] + fn test_from_hex() { + let hex = b"0123456789abcdefABCDEF"; + + let max = u8::MAX as i32 + 1; + for i in 0..max { + let c = i as u8; + if hex.contains(&c) { + assert!(from_hex(c).is_some()) + } else { + assert!(from_hex(c).is_none()) + } + } + } }