From f2f0f94bc16343408c6a53ac87d3e4f43ac80e5f Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Mon, 11 Dec 2023 15:07:47 -0800 Subject: [PATCH] Add unit test to str --- src/str.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/str.rs b/src/str.rs index adcc3f8..056df39 100644 --- a/src/str.rs +++ b/src/str.rs @@ -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 { } 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); +}