summaryrefslogtreecommitdiff
path: root/tools/slang-test/unit-test-find-type-by-name.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-09-24 11:33:44 -0700
committerGitHub <noreply@github.com>2021-09-24 11:33:44 -0700
commitbec8e6aec85b6e3f875c58bdd59eb15613978358 (patch)
tree0791fb2ce1be786c17e5a6ee489ed3065fc07332 /tools/slang-test/unit-test-find-type-by-name.cpp
parentf2a3c933bc11a498c622fa18694c84beca8ca031 (diff)
Move existing unit tests to a standalone dll. (#1945)
Diffstat (limited to 'tools/slang-test/unit-test-find-type-by-name.cpp')
-rw-r--r--tools/slang-test/unit-test-find-type-by-name.cpp56
1 files changed, 0 insertions, 56 deletions
diff --git a/tools/slang-test/unit-test-find-type-by-name.cpp b/tools/slang-test/unit-test-find-type-by-name.cpp
deleted file mode 100644
index ebe5f746b..000000000
--- a/tools/slang-test/unit-test-find-type-by-name.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// unit-test-byte-encode.cpp
-
-#include "../../slang.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "test-context.h"
-
-using namespace Slang;
-
-static void findTypeByNameTest()
-{
- const char* testSource =
- "struct TestStruct {"
- " int member0;"
- " Texture2D texture1;"
- "};";
- auto session = spCreateSession();
- auto request = spCreateCompileRequest(session);
- spAddCodeGenTarget(request, SLANG_DXBC);
- int tuIndex = spAddTranslationUnit(request, SLANG_SOURCE_LANGUAGE_SLANG, "tu1");
- spAddTranslationUnitSourceString(request, tuIndex, "internalFile", testSource);
- spCompile(request);
-
- auto testBody = [&]()
- {
- auto reflection = slang::ShaderReflection::get(request);
- auto testStruct = reflection->findTypeByName("TestStruct");
- SLANG_CHECK_ABORT(testStruct->getFieldCount() == 2);
- auto field0Name = testStruct->getFieldByIndex(0)->getName();
- SLANG_CHECK_ABORT(field0Name != nullptr && strcmp(field0Name, "member0") == 0);
- auto field1Name = testStruct->getFieldByIndex(1)->getName();
- SLANG_CHECK_ABORT(field1Name != nullptr && strcmp(field1Name, "texture1") == 0);
-
- auto intType = reflection->findTypeByName("int");
- auto intTypeName = intType->getName();
- SLANG_CHECK_ABORT(intTypeName && strcmp(intTypeName, "int") == 0);
-
- auto paramBlockType = reflection->findTypeByName("ParameterBlock<TestStruct>");
- SLANG_CHECK_ABORT(paramBlockType != nullptr);
- auto paramBlockTypeName = paramBlockType->getName();
- SLANG_CHECK_ABORT(paramBlockTypeName && strcmp(paramBlockTypeName, "ParameterBlock") == 0);
- auto paramBlockElementType = paramBlockType->getElementType();
- SLANG_CHECK_ABORT(paramBlockElementType != nullptr);
- auto paramBlockElementTypeName = paramBlockElementType->getName();
- SLANG_CHECK_ABORT(paramBlockElementTypeName && strcmp(paramBlockElementTypeName, "TestStruct") == 0);
- };
-
- testBody();
-
- spDestroyCompileRequest(request);
- spDestroySession(session);
-}
-
-SLANG_UNIT_TEST("findTypeByName", findTypeByNameTest);