diff options
Diffstat (limited to 'source/test/byte_array_test.cpp')
-rw-r--r-- | source/test/byte_array_test.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/test/byte_array_test.cpp b/source/test/byte_array_test.cpp new file mode 100644 index 0000000..0c74b1c --- /dev/null +++ b/source/test/byte_array_test.cpp @@ -0,0 +1,33 @@ +#include "StarByteArray.hpp" +#include "StarEncode.hpp" + +#include "gtest/gtest.h" + +using namespace Star; + +TEST(ByteArrayTest, All) { + auto res = ByteArray::fromCString("foobar"); + res.insert(2, 'a'); + res.insert(6, 'b'); + res.push_back('c'); + res.insert(9, 'd'); + EXPECT_EQ(res, ByteArray::fromCString("foaobabrcd")); + + auto a = hexDecode("0a0a0a"); + auto b = hexDecode("a0a0a0"); + auto c = hexDecode("818181"); + auto d = hexDecode("aaaaaa"); + auto e = hexDecode("000000"); + auto f = hexDecode("212121"); + + auto g = hexDecode("a0a0a0"); + auto h = hexDecode("8181818181"); + auto i = hexDecode("2121218181"); + + EXPECT_EQ(a.andWith(b), e); + EXPECT_EQ(a.orWith(b), d); + EXPECT_EQ(b.xorWith(c), f); + EXPECT_EQ(g.xorWith(h), f); + EXPECT_EQ(g.xorWith(h, true), i); + EXPECT_EQ(h.xorWith(g, true), i); +} |