From b8982fcf43b86c1e39dcc3dd19bff2821633eda6 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 9 Feb 2022 15:30:38 -0800 Subject: Various fixes to gfx. (#2120) * Various fixes to gfx. * Fix. * Fixes. * Fix. Co-authored-by: Yong He --- tools/slang-unit-test/unit-test-chunked-list.cpp | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tools/slang-unit-test/unit-test-chunked-list.cpp (limited to 'tools/slang-unit-test/unit-test-chunked-list.cpp') diff --git a/tools/slang-unit-test/unit-test-chunked-list.cpp b/tools/slang-unit-test/unit-test-chunked-list.cpp new file mode 100644 index 000000000..af4f597b2 --- /dev/null +++ b/tools/slang-unit-test/unit-test-chunked-list.cpp @@ -0,0 +1,41 @@ +// unit-test-path.cpp + +#include "source/core/slang-basic.h" +#include "source/core/slang-chunked-list.h" +#include "tools/unit-test/slang-unit-test.h" + +using namespace Slang; + +template +static bool _checkArrayView(ArrayView v0, ArrayView v1) +{ + if (v0.getCount() != v1.getCount()) + return false; + for (Index i = 0; i < v0.getCount(); i++) + if (v0[i] != v1[i]) + return false; + return true; +} + +SLANG_UNIT_TEST(chunkedList) +{ + { + ChunkedList stringList; + List ptrs; + for (int i = 0; i < 256; i++) + { + ptrs.add(stringList.add(String(i))); + } + SLANG_CHECK(stringList.getCount() == 256); + SLANG_CHECK(*(ptrs[128]) == "128"); + + stringList.clearAndDeallocate(); + ptrs.clear(); + for (int i = 0; i < 64; i++) + { + ptrs.add(stringList.add(String(i))); + } + SLANG_CHECK(stringList.getCount() == 64); + SLANG_CHECK(*(ptrs[32]) == "32"); + } +} -- cgit v1.2.3