From 7c35a5332018ea604be2e678bf955e39a8841678 Mon Sep 17 00:00:00 2001 From: revsic Date: Thu, 14 Feb 2019 19:12:57 +0900 Subject: [PATCH] test, string obfs: Add xor string obfuscator tests --- test/impl/string_obfs.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/impl/string_obfs.cpp diff --git a/test/impl/string_obfs.cpp b/test/impl/string_obfs.cpp new file mode 100644 index 0000000..c160b80 --- /dev/null +++ b/test/impl/string_obfs.cpp @@ -0,0 +1,16 @@ +#include +#include + +TEST_CASE("xor string obfs", "[StringObfs]") { + using byte = unsigned char; + + auto xor = [](byte key) constexpr { + return [=](char c) constexpr -> char { + return c ^ key; + }; + }; + + REQUIRE( + make_stringobfs("Hello World !", xor(0x20), xor(0x20)).decode() + == std::string_view("Hello World !")); +} \ No newline at end of file