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-riff.cpp | 47 +++++++++++++++++++------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'tools/slang-unit-test/unit-test-riff.cpp') 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& ioData) +static void _writeRandom( + RandomGenerator* rand, + size_t maxSize, + RiffContainer& ioContainer, + List& 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(ioContainer.getCurrentChunk()); + RiffContainer::DataChunk* dataChunk = + as(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 rand = RandomGenerator::create(0x345234); List 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(container.getCurrentChunk()); + RiffContainer::DataChunk* dataChunk = + as(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 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 data; _writeRandom(rand, maxSize, container, data); // Should be a single block with same data as the List - RiffContainer::DataChunk* dataChunk = as(container.getCurrentChunk()); + RiffContainer::DataChunk* dataChunk = + as(container.getCurrentChunk()); SLANG_CHECK(dataChunk && dataChunk->isEqual(data.getBuffer(), data.getCount())); } } @@ -176,4 +186,3 @@ SLANG_UNIT_TEST(riff) } #endif } - -- cgit v1.2.3