Browse Source

Tests: test_hexbin.cc - we are always in namepace ::pEp

LIB-19
heck 4 years ago
parent
commit
a17dddf716
  1. 14
      test/test_hexbin.cc

14
test/test_hexbin.cc

@ -4,7 +4,7 @@
#include <cassert> #include <cassert>
#include <pEp/pitytest11/PityTest.hh> #include <pEp/pitytest11/PityTest.hh>
using namespace pEp::Utils; using namespace pEp;
int main() int main()
{ {
@ -13,26 +13,26 @@ int main()
{ {
// Valid hex string // Valid hex string
std::string str_in{ "FFABCD00EF123200" }; std::string str_in{ "FFABCD00EF123200" };
std::vector<unsigned char> bin = pEp::Utils::hex2bin(str_in); std::vector<unsigned char> bin = Utils::hex2bin(str_in);
PITYASSERT(str_in.length() == bin.size() * 2, "Size error"); PITYASSERT(str_in.length() == bin.size() * 2, "Size error");
std::string str_out = pEp::Utils::bin2hex(bin); std::string str_out = pEp::Utils::bin2hex(bin);
pEpLog("Hex_IN : '" + to_lower(str_in) + "'"); pEpLog("Hex_IN : '" + Utils::to_lower(str_in) + "'");
pEpLog("Hex_OUT : '" + to_lower(str_out) + "'"); pEpLog("Hex_OUT : '" + Utils::to_lower(str_out) + "'");
PITYASSERT(to_lower(str_in) == to_lower(str_out), "roundtrip failed"); PITYASSERT(Utils::to_lower(str_in) == Utils::to_lower(str_out), "roundtrip failed");
} }
{ {
// Uneven string throws // Uneven string throws
std::string str_in{ "FFA" }; std::string str_in{ "FFA" };
PITYASSERT_THROWS(pEp::Utils::hex2bin(str_in), "Uneven string should throw"); PITYASSERT_THROWS(Utils::hex2bin(str_in), "Uneven string should throw");
} }
{ {
// Non-hex chars // Non-hex chars
std::string str_in{ "pEp!" }; std::string str_in{ "pEp!" };
PITYASSERT_THROWS(pEp::Utils::hex2bin(str_in), "Invalid hex chars should throw"); PITYASSERT_THROWS(Utils::hex2bin(str_in), "Invalid hex chars should throw");
} }
pEpLog("All tests passsed"); pEpLog("All tests passsed");

Loading…
Cancel
Save