From 2bc44af7e332aadaa2ef9d4fcef549827cb32874 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Fri, 29 Nov 2024 17:12:53 +0000 Subject: [PATCH] test: add test for percent_encode_byte_array --- packages/tracker-client/src/http/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/tracker-client/src/http/mod.rs b/packages/tracker-client/src/http/mod.rs index 15723c1b7..d8f8242e8 100644 --- a/packages/tracker-client/src/http/mod.rs +++ b/packages/tracker-client/src/http/mod.rs @@ -24,3 +24,19 @@ impl InfoHash { self.0 } } + +#[cfg(test)] +mod tests { + use crate::http::percent_encode_byte_array; + + #[test] + fn it_should_encode_a_20_byte_array() { + assert_eq!( + percent_encode_byte_array(&[ + 0x3b, 0x24, 0x55, 0x04, 0xcf, 0x5f, 0x11, 0xbb, 0xdb, 0xe1, 0x20, 0x1c, 0xea, 0x6a, 0x6b, 0xf4, 0x5a, 0xee, 0x1b, + 0xc0, + ]), + "%3B%24U%04%CF%5F%11%BB%DB%E1%20%1C%EAjk%F4Z%EE%1B%C0" + ); + } +}