diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
commit | 6352e8e3196f78388b6c771073f9e03eaa612673 (patch) | |
tree | e23772f79a7fbc41bc9108951e9e136857484bf4 /source/test/byte_array_test.cpp | |
parent | 6741a057e5639280d85d0f88ba26f000baa58f61 (diff) |
everything everywhere
all at once
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); +} |