fix from_hex
@@ -1798,8 +1798,7 @@ fn get_module_type(module: &str) -> MODULE {
}
fn from_hex(key: &str) -> Result<Vec<u8>, FromHexError> {
- const HEX_PREFIX: &str = "0x";
- if key.starts_with(HEX_PREFIX) {
+ if key.starts_with("0x") || key.starts_with("0X") {
return key[2..].from_hex();
}
key.from_hex()
@@ -1982,3 +1981,16 @@ fn read_fail_file(path: &str) -> Vec<(String, String)> {
}
list
}
+
+#[cfg(test)]
+mod tests {
+ use super::from_hex;
+
+ #[test]
+ fn test_from_hex() {
+ let result = vec![0x74];
+ assert_eq!(from_hex("74").unwrap(), result);
+ assert_eq!(from_hex("0x74").unwrap(), result);
+ assert_eq!(from_hex("0X74").unwrap(), result);
+ }
+}
