diff options
| author | Yong He <yonghe@outlook.com> | 2021-09-24 11:33:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-24 11:33:44 -0700 |
| commit | bec8e6aec85b6e3f875c58bdd59eb15613978358 (patch) | |
| tree | 0791fb2ce1be786c17e5a6ee489ed3065fc07332 /tools/slang-test/unit-test-free-list.cpp | |
| parent | f2a3c933bc11a498c622fa18694c84beca8ca031 (diff) | |
Move existing unit tests to a standalone dll. (#1945)
Diffstat (limited to 'tools/slang-test/unit-test-free-list.cpp')
| -rw-r--r-- | tools/slang-test/unit-test-free-list.cpp | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/tools/slang-test/unit-test-free-list.cpp b/tools/slang-test/unit-test-free-list.cpp deleted file mode 100644 index 28973d9e5..000000000 --- a/tools/slang-test/unit-test-free-list.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// unit-test-free-list.cpp - -#include "../../source/core/slang-free-list.h" - -#include <stdio.h> -#include <stdlib.h> - -#include "test-context.h" - -#include "../../source/core/slang-random-generator.h" -#include "../../source/core/slang-list.h" - -using namespace Slang; - -static void freeListUnitTest() -{ - FreeList freeList; - freeList.init(sizeof(int), sizeof(void*), 10); - - DefaultRandomGenerator randGen(0x24343); - - List<int*> allocs; - - for (int i = 0; i < 1000; i++) - { - const int numAlloc = randGen.nextInt32UpTo(20); - - for (int j = 0; j < numAlloc; j++) - { - int* ptr = (int*)freeList.allocate(); - *ptr = i; - allocs.add(ptr); - } - - int numDealloc = randGen.nextInt32UpTo(19); - numDealloc = int(allocs.getCount()) < numDealloc ? int(allocs.getCount()) : numDealloc; - - for (int j = 0; j < numDealloc; j++) - { - const int index = randGen.nextInt32UpTo(int(allocs.getCount())); - - int* alloc = allocs[index]; - - SLANG_CHECK(*alloc <= i); - SLANG_CHECK(*alloc >= 0); - - freeList.deallocate(alloc); - - allocs.fastRemoveAt(index); - } - } -} - -SLANG_UNIT_TEST("FreeList", freeListUnitTest); |
