From f5856d75915bc0e1e5cdb218b5e64267e300f652 Mon Sep 17 00:00:00 2001 From: James Wilson Date: Fri, 13 May 2022 14:17:53 -0700 Subject: [PATCH] Test for key_from_hex_chars (#70) --- tests/output.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/output.cpp b/tests/output.cpp index dbe3865..6e0628d 100644 --- a/tests/output.cpp +++ b/tests/output.cpp @@ -10,6 +10,20 @@ using namespace std::literals::string_literals; +TEST_CASE("Test key_from_hex_chars", "[output]") +{ + REQUIRE(key_from_hex_chars(""s) == std::vector {}); + REQUIRE(key_from_hex_chars("hello"s) == std::nullopt); + REQUIRE(key_from_hex_chars("12z"s) == std::nullopt); + REQUIRE(key_from_hex_chars("0xabcd"s) == std::nullopt); + REQUIRE(key_from_hex_chars("ab cd"s) == std::nullopt); + REQUIRE(key_from_hex_chars("a"s) == std::vector {0x0a}); + REQUIRE(key_from_hex_chars("0123456789abcdef"s) == + std::vector {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}); + REQUIRE(key_from_hex_chars("0123456789ABCDEF"s) == + std::vector {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}); +} + /** * Compare the output of stenc given device responses *