From f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Oct 2024 14:49:26 +0800 Subject: format * format * Minor test fixes * enable checking cpp format in ci --- tools/slang-unit-test/unit-test-byte-encode.cpp | 45 ++++++++++++++----------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'tools/slang-unit-test/unit-test-byte-encode.cpp') diff --git a/tools/slang-unit-test/unit-test-byte-encode.cpp b/tools/slang-unit-test/unit-test-byte-encode.cpp index 38bd5561d..36b9f91d8 100644 --- a/tools/slang-unit-test/unit-test-byte-encode.cpp +++ b/tools/slang-unit-test/unit-test-byte-encode.cpp @@ -1,15 +1,13 @@ // unit-test-byte-encode.cpp #include "../../source/core/slang-byte-encode-util.h" +#include "../../source/core/slang-list.h" +#include "../../source/core/slang-random-generator.h" +#include "tools/unit-test/slang-unit-test.h" #include #include -#include "tools/unit-test/slang-unit-test.h" - -#include "../../source/core/slang-random-generator.h" -#include "../../source/core/slang-list.h" - using namespace Slang; static void checkUInt32(uint32_t value) @@ -91,28 +89,38 @@ SLANG_UNIT_TEST(byteEncode) { const int v = ByteEncodeUtil::calcMsb8(uint32_t((randGen.nextInt32() & 0xf) | 1)); - // Make the commonality of different numbers that bytes are most common, then shorts etc.. + // Make the commonality of different numbers that bytes are most common, then shorts + // etc.. uint32_t mask; switch (v) { - case 0: mask = 0xffffffff; break; - case 1: mask = 0x00ffffff; break; - case 2: mask = 0x0000ffff; break; - case 3: mask = 0x000000ff; break; + case 0: mask = 0xffffffff; break; + case 1: mask = 0x00ffffff; break; + case 2: mask = 0x0000ffff; break; + case 3: mask = 0x000000ff; break; } initialBuffer[i] = randGen.nextInt32() & mask; } - - size_t numEncodeBytes = ByteEncodeUtil::encodeLiteUInt32(initialBuffer.begin(), blockSize, encodedBuffer.begin()); - SLANG_CHECK(ByteEncodeUtil::calcEncodeLiteSizeUInt32(initialBuffer.begin(), blockSize) == numEncodeBytes); + size_t numEncodeBytes = ByteEncodeUtil::encodeLiteUInt32( + initialBuffer.begin(), + blockSize, + encodedBuffer.begin()); + + SLANG_CHECK( + ByteEncodeUtil::calcEncodeLiteSizeUInt32(initialBuffer.begin(), blockSize) == + numEncodeBytes); + + size_t numEncodeBytes2 = ByteEncodeUtil::decodeLiteUInt32( + encodedBuffer.begin(), + blockSize, + decodeBuffer.begin()); - size_t numEncodeBytes2 = ByteEncodeUtil::decodeLiteUInt32(encodedBuffer.begin(), blockSize, decodeBuffer.begin()); - SLANG_CHECK(numEncodeBytes2 == numEncodeBytes); - - SLANG_CHECK(memcmp(decodeBuffer.begin(), initialBuffer.begin(), sizeof(uint32_t) * blockSize) == 0); + + SLANG_CHECK( + memcmp(decodeBuffer.begin(), initialBuffer.begin(), sizeof(uint32_t) * blockSize) == 0); } { @@ -134,6 +142,5 @@ SLANG_UNIT_TEST(byteEncode) checkUInt32(uint32_t(i)); } #endif - } - + } } -- cgit v1.2.3