diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-03-05 16:21:30 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-03-05 16:21:30 +0200 |
commit | 5bbbe3902b4ee77ca1eb23edc0b5495812353b1f (patch) | |
tree | 16ab3b2aedec9e6b68ee8254434fbb937ecb37f3 /tests/unit_tests | |
parent | Merge pull request #5119 (diff) | |
parent | epee: add SSL support (diff) | |
download | monero-5bbbe3902b4ee77ca1eb23edc0b5495812353b1f.tar.xz |
Merge pull request #4852
057c279c epee: add SSL support (Martijn Otto)
Diffstat (limited to 'tests/unit_tests')
-rw-r--r-- | tests/unit_tests/epee_utils.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp index 18fb262c2..9a32d149a 100644 --- a/tests/unit_tests/epee_utils.cpp +++ b/tests/unit_tests/epee_utils.cpp @@ -389,6 +389,25 @@ TEST(ToHex, String) } +TEST(FromHex, String) +{ + // the source data to encode and decode + std::vector<uint8_t> source{{ 0x00, 0xFF, 0x0F, 0xF0 }}; + + // encode and decode the data + auto hex = epee::to_hex::string({ source.data(), source.size() }); + auto decoded = epee::from_hex::vector(hex); + + // encoded should be twice the size and should decode to the exact same data + EXPECT_EQ(source.size() * 2, hex.size()); + EXPECT_EQ(source, decoded); + + // we will now create a padded hex string, we want to explicitly allow + // decoding it this way also, ignoring spaces and colons between the numbers + hex.assign("00:ff 0f:f0"); + EXPECT_EQ(source, epee::from_hex::vector(hex)); +} + TEST(ToHex, Array) { EXPECT_EQ( |