Skip to content

Commit

Permalink
added shadder pp unit tests for new functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
richardeakin committed Mar 22, 2017
1 parent d7806e0 commit 29b90b6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/unit/src/ShaderPreprocessorTest.cpp
Expand Up @@ -57,6 +57,37 @@ TEST_CASE( "ShaderPreprocessor" )
REQUIRE( result.find( "#define SOMEVAR 2" ) != string::npos );
}

SECTION( "test remove define" )
{
gl::ShaderPreprocessor preprocessor;
preprocessor.addDefine( "BLARG" );
preprocessor.addDefine( "SOMEVAR", "2" );

preprocessor.removeDefine( "BLARG" );
preprocessor.removeDefine( "SOMEVAR" );

REQUIRE( preprocessor.getDefines().size() == 0 );

const string result = preprocessor.parse( app::getAssetPath( "shader_preprocessor/simple.frag" ) );

REQUIRE( result.find( "#define BLARG" ) == string::npos );
REQUIRE( result.find( "#define SOMEVAR 2" ) == string::npos );
}

SECTION( "test overwrite define" )
{
gl::ShaderPreprocessor preprocessor;
preprocessor.addDefine( "SOMEVAR", "1" );
preprocessor.addDefine( "SOMEVAR", "2" );

REQUIRE( preprocessor.getDefines().size() == 1 );

const string result = preprocessor.parse( app::getAssetPath( "shader_preprocessor/simple.frag" ) );

REQUIRE( result.find( "#define SOMEVAR 1" ) == string::npos );
REQUIRE( result.find( "#define SOMEVAR 2" ) != string::npos );
}

SECTION( "test nested includes" )
{
gl::ShaderPreprocessor preprocessor;
Expand Down

0 comments on commit 29b90b6

Please sign in to comment.