yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
7b570feed
master
1#include "slang-unit-test.h" 2 3#include "core/slang-basic.h" 4#include "slang.h" 5 6struct SlangUnitTest 7{ 8const char * name ; 9UnitTestFunc func ; 10}; 11 12class SlangUnitTestModule :public IUnitTestModule 13{ 14public : 15Slang ::List < SlangUnitTest > tests ; 16ITestReporter * testReporter = nullptr ; 17 18virtual SLANG_NO_THROW SlangInt SLANG_MCALL getTestCount ()override {return tests .getCount (); } 19virtual SLANG_NO_THROW const char * SLANG_MCALL getTestName (SlangInt index )override 20 { 21return tests [index ].name ; 22 } 23 24virtual SLANG_NO_THROW UnitTestFunc SLANG_MCALL getTestFunc (SlangInt index )override 25 { 26return tests [index ].func ; 27 } 28 29virtual SLANG_NO_THROW void SLANG_MCALL setTestReporter (ITestReporter * reporter )override 30 { 31testReporter = reporter ; 32 } 33 34virtual SLANG_NO_THROW void SLANG_MCALL destroy ()override {tests = decltype(tests )(); } 35}; 36 37SlangUnitTestModule * _getTestModule () 38{ 39static SlangUnitTestModule testModule ; 40return & testModule ; 41} 42 43ITestReporter * getTestReporter () 44{ 45return _getTestModule ()-> testReporter ; 46} 47 48extern "C" 49{ 50SLANG_DLL_EXPORT IUnitTestModule * slangUnitTestGetModule () 51 { 52return _getTestModule (); 53 } 54} 55 56UnitTestRegisterHelper ::UnitTestRegisterHelper (const char * name ,UnitTestFunc testFunc ) 57{ 58_getTestModule ()-> tests .add (SlangUnitTest {name ,testFunc }); 59}