From 6352e8e3196f78388b6c771073f9e03eaa612673 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:33:09 +1000 Subject: everything everywhere all at once --- source/test/byte_array_test.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 source/test/byte_array_test.cpp (limited to 'source/test/byte_array_test.cpp') 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); +} -- cgit v1.2.3