| 6 | using namespace Star; |
| 7 | |
| 8 | TEST(ByteArrayTest, All) { |
| 9 | auto res = ByteArray::fromCString("foobar"); |
| 10 | res.insert(2, 'a'); |
| 11 | res.insert(6, 'b'); |
| 12 | res.push_back('c'); |
| 13 | res.insert(9, 'd'); |
| 14 | EXPECT_EQ(res, ByteArray::fromCString("foaobabrcd")); |
| 15 | |
| 16 | auto a = hexDecode("0a0a0a"); |
| 17 | auto b = hexDecode("a0a0a0"); |
| 18 | auto c = hexDecode("818181"); |
| 19 | auto d = hexDecode("aaaaaa"); |
| 20 | auto e = hexDecode("000000"); |
| 21 | auto f = hexDecode("212121"); |
| 22 | |
| 23 | auto g = hexDecode("a0a0a0"); |
| 24 | auto h = hexDecode("8181818181"); |
| 25 | auto i = hexDecode("2121218181"); |
| 26 | |
| 27 | EXPECT_EQ(a.andWith(b), e); |
| 28 | EXPECT_EQ(a.orWith(b), d); |
| 29 | EXPECT_EQ(b.xorWith(c), f); |
| 30 | EXPECT_EQ(g.xorWith(h), f); |
| 31 | EXPECT_EQ(g.xorWith(h, true), i); |
| 32 | EXPECT_EQ(h.xorWith(g, true), i); |
| 33 | } |