Add unit test to str

This commit is contained in:
Joseph Henry
2023-12-11 15:07:47 -08:00
parent 80f8726f82
commit f2f0f94bc1
+11
View File
@@ -6,6 +6,8 @@
* https://www.zerotier.com/
*/
use serde::de::Unexpected;
use crate::hex::HEX_CHARS;
/// Escape non-ASCII-printable characters in a string.
@@ -54,3 +56,12 @@ pub fn unescape(s: &str) -> Vec<u8> {
}
b
}
#[test]
fn test_unescape() {
let s = "\\000";
let unescaped = unescape(s);
let escaped = escape(&unescaped);
assert_eq!(escaped, "\\000");
assert_eq!(unescaped[0], 0);
}