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-riff.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'tools/slang-unit-test/unit-test-riff.cpp')
| -rw-r--r-- | tools/slang-unit-test/unit-test-riff.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/tools/slang-unit-test/unit-test-riff.cpp b/tools/slang-unit-test/unit-test-riff.cpp index 2902a9af5..a0eb91a47 100644 --- a/tools/slang-unit-test/unit-test-riff.cpp +++ b/tools/slang-unit-test/unit-test-riff.cpp @@ -1,14 +1,16 @@ // unit-test-riff.cpp -#include "../../source/core/slang-riff.h" - #include "../../source/core/slang-random-generator.h" - +#include "../../source/core/slang-riff.h" #include "tools/unit-test/slang-unit-test.h" using namespace Slang; -static void _writeRandom(RandomGenerator* rand, size_t maxSize, RiffContainer& ioContainer, List<uint8_t>& ioData) +static void _writeRandom( + RandomGenerator* rand, + size_t maxSize, + RiffContainer& ioContainer, + List<uint8_t>& ioData) { while (true) { @@ -29,7 +31,8 @@ static void _writeRandom(RandomGenerator* rand, size_t maxSize, RiffContainer& i } // Should be a single block with same data as the List - RiffContainer::DataChunk* dataChunk = as<RiffContainer::DataChunk>(ioContainer.getCurrentChunk()); + RiffContainer::DataChunk* dataChunk = + as<RiffContainer::DataChunk>(ioContainer.getCurrentChunk()); SLANG_ASSERT(dataChunk); } @@ -45,7 +48,7 @@ SLANG_UNIT_TEST(riff) RiffContainer container; { - ScopeChunk scopeContainer(&container, Kind::List, markThings); + ScopeChunk scopeContainer(&container, Kind::List, markThings); { ScopeChunk scopeChunk(&container, Kind::Data, markData); @@ -89,7 +92,7 @@ SLANG_UNIT_TEST(riff) } { - OwnedMemoryStream stream(FileAccess::ReadWrite); + OwnedMemoryStream stream(FileAccess::ReadWrite); SLANG_CHECK(SLANG_SUCCEEDED(RiffUtil::write(container.getRoot(), true, &stream))); stream.seek(SeekOrigin::Start, 0); @@ -108,10 +111,10 @@ SLANG_UNIT_TEST(riff) SLANG_CHECK(readBuilder == builder); } } - } - // Test writing as a stream only allocates a single data block (as long as there is enough space). + // Test writing as a stream only allocates a single data block (as long as there is enough + // space). { RiffContainer container; @@ -121,39 +124,46 @@ SLANG_UNIT_TEST(riff) RefPtr<RandomGenerator> rand = RandomGenerator::create(0x345234); List<uint8_t> data; - _writeRandom(rand, container.getMemoryArena().getBlockPayloadSize() / 2, container, data); + _writeRandom( + rand, + container.getMemoryArena().getBlockPayloadSize() / 2, + container, + data); // Should be a single block with same data as the List - RiffContainer::DataChunk* dataChunk = as<RiffContainer::DataChunk>(container.getCurrentChunk()); + RiffContainer::DataChunk* dataChunk = + as<RiffContainer::DataChunk>(container.getCurrentChunk()); SLANG_ASSERT(dataChunk); // It should be a single block SLANG_CHECK(dataChunk->getSingleData() != nullptr); SLANG_CHECK(dataChunk->isEqual(data.getBuffer(), data.getCount())); - } - } + } // Test writing across multiple data blocks { RefPtr<RandomGenerator> rand = RandomGenerator::create(0x345234); - for (Int i = 0 ; i < 100; ++i) + for (Int i = 0; i < 100; ++i) { RiffContainer container; - const size_t maxSize = rand->nextInt32InRange(1, int32_t(container.getMemoryArena().getBlockPayloadSize() * 3)); - + const size_t maxSize = rand->nextInt32InRange( + 1, + int32_t(container.getMemoryArena().getBlockPayloadSize() * 3)); + ScopeChunk scopeChunk(&container, Kind::List, markData); { ScopeChunk scopeChunk(&container, Kind::Data, markData); - + List<uint8_t> data; _writeRandom(rand, maxSize, container, data); // Should be a single block with same data as the List - RiffContainer::DataChunk* dataChunk = as<RiffContainer::DataChunk>(container.getCurrentChunk()); + RiffContainer::DataChunk* dataChunk = + as<RiffContainer::DataChunk>(container.getCurrentChunk()); SLANG_CHECK(dataChunk && dataChunk->isEqual(data.getBuffer(), data.getCount())); } } @@ -176,4 +186,3 @@ SLANG_UNIT_TEST(riff) } #endif } - |
