diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /tools/slang-unit-test/unit-test-byte-encode.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'tools/slang-unit-test/unit-test-byte-encode.cpp')
| -rw-r--r-- | tools/slang-unit-test/unit-test-byte-encode.cpp | 45 |
1 files changed, 26 insertions, 19 deletions
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 <stdio.h> #include <stdlib.h> -#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 - } - + } } |
