32 #include <gtest/gtest.h>
44 using CharVec = std::vector<char>;
51 TEST(hex, hex_to_bin_all)
53 CharVec allbin(256, 0);
54 for (
int i = 0; i < 256; i++)
59 Hex::bin_to_hex(allbin, hex);
60 cout <<
"Hex: " << hex << endl;
61 ASSERT_EQ(hex.size(), 512);
64 Hex::hex_to_bin(hex, newbin);
65 ASSERT_EQ(newbin.size(), 256);
66 ASSERT_EQ(allbin, newbin);
68 cout <<
"bin to hex string:" << endl;
69 cout << Hex::bin_to_hexstr(allbin,
":", 20) << endl;
75 Hex::bin_to_hex(CharVec(z.begin(), z.end()), s);
76 ASSERT_EQ(s.size(), 0);
81 string bin =
"this is a test";
82 string hex1 =
"7468697320697320612074657374";
84 Hex::bin_to_hex(CharVec(bin.begin(), bin.end()), hex2);
85 ASSERT_EQ(hex1, hex2);
88 TEST(hex, hex_to_bin_part)
90 string corrupthex =
"7468697......!";
91 string validbin =
"thi";
92 CharVec bin, val(validbin.begin(), validbin.end());
93 Hex::hex_to_bin(corrupthex, bin);
Binary to hex string converter.
TEST(inet_example, client_server_stream_test)
[Inet client server]