yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
7b570feed
master
1// unit-test-io.cpp 2 3#include "../../source/core/slang-io.h" 4#include "unit-test/slang-unit-test.h" 5 6using namespace Slang ; 7 8static SlangResult _checkGenerateTemporary () 9{ 10/// Test temporary file functionality 11 12List < String > paths ; 13 14for (Index i = 0 ;i < 10 ;++ i ) 15 { 16String path ; 17SLANG_RETURN_ON_FAIL (File ::generateTemporary (toSlice ("slang-check" ),path )); 18 19// The path should exist exist 20SLANG_CHECK (File ::exists (path )); 21 22if (paths .contains (path )) 23 { 24return SLANG_FAIL ; 25 } 26 27paths .add (path ); 28 } 29 30// It should be possible to write to the temporary files 31for (auto & path :paths ) 32 { 33SLANG_RETURN_ON_FAIL (File ::writeAllText (path ,path )); 34 } 35// It should be possible to read from the temporary files 36 37for (auto & path :paths ) 38 { 39String contents ; 40SLANG_RETURN_ON_FAIL (File ::readAllText (path ,contents )) 41 42SLANG_CHECK (contents == path ); 43 } 44 45// Remove all the temporary files 46for (auto & path :paths ) 47 { 48SLANG_CHECK (File ::exists (path )); 49 50const auto removeResult = File ::remove (path ); 51SLANG_CHECK (SLANG_SUCCEEDED (removeResult )); 52 53// Check remove worked 54SLANG_CHECK (!File ::exists (path )); 55 } 56 57return SLANG_OK ; 58} 59 60SLANG_UNIT_TEST (io ) 61{ 62SLANG_CHECK (SLANG_SUCCEEDED (_checkGenerateTemporary ())); 63}