From 7218b653ecda483790af5a71c072af0918de9292 Mon Sep 17 00:00:00 2001 From: raperez2 <70178601+raperez2@users.noreply.github.com> Date: Wed, 8 May 2024 00:21:05 -0700 Subject: [PATCH] Added ByteBuf Added some tests for ByteBuf, they probably don't work. How can I change that? --- DAWdleUnitTesting/UnitTesting.cpp | 64 ++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/DAWdleUnitTesting/UnitTesting.cpp b/DAWdleUnitTesting/UnitTesting.cpp index 1ec9f31..e1f663a 100644 --- a/DAWdleUnitTesting/UnitTesting.cpp +++ b/DAWdleUnitTesting/UnitTesting.cpp @@ -751,7 +751,7 @@ namespace MemoryTests { } TEST(Strcmp, MultiByteCharacters) { - EXPECT_GT(strcmp("éstevan", "estevan"), 0); + EXPECT_GT(strcmp("éstevan", "estevan"), 0); } TEST(Strcmp, NullTerminatedCheck) { @@ -811,4 +811,64 @@ namespace MemoryTests { char buffer2[10] = "hello"; EXPECT_EQ(memcmp(buffer1, buffer2, 3), 0); } -} \ No newline at end of file +} + +namespace ByteBuffer { + + const StrA str = "dawdleDotcom"sa; + + TEST(ByteBuff, Wrap) { + ByteBuf test; + U8 testValue = 'a'; + U8* testdata = &testValue; + U32 dataSize = sizeof(testdata); + test.wrap(testdata, dataSize); + EXPECT_EQ(test.bytes, 'a'); + } + + TEST(ByteBuff, has_data_left) { + ByteBuf test; + U8 testValue = 'a'; + U8* testdata = &testValue; + U32 dataSize = sizeof(testdata); + test.wrap(testdata, dataSize); + EXPECT_TRUE(test.has_data_left(dataSize)); + } + + TEST(ByteBuff, skip) { + ByteBuf test; + U8 testValue = 'a'; + U8* testdata = &testValue; + U32 dataSize = sizeof(testdata); + test.wrap(testdata, dataSize); + test.skip(1); + EXPECT_EQ(test.bytes, 'a'); + } + + TEST(ByteBuff, read_bytes) { + ByteBuf test; + U8 testValue = 'a'; + U8* testdata = &testValue; + U32 dataSize = sizeof(testdata); + test.read_bytes(testdata, dataSize); + EXPECT_EQ(test.bytes, 'a'); + } + + TEST(ByteBuff, write_bytes) { + ByteBuf test; + ByteBuf result; + U8 testValue = 'a'; + U8* testdata = &testValue; + U32 dataSize = sizeof(testdata); + result = test.write_bytes(testdata, dataSize); + EXPECT_EQ(test.bytes, result); + } + + TEST(ByteBuff, write_stra) { + ByteBuf test; + ByteBuf result; + result = test.write_stra(str); + EXPECT_EQ(test.bytes, result); + } + +}