@ -44,6 +44,7 @@ struct AnyConverterTest: TestSuite::Tester {
explicit AnyConverterTest ( ) ;
void validate ( ) ;
void validateUnknown ( ) ;
void validateNotSupported ( ) ;
void validatePreprocessNotSupported ( ) ;
void validatePropagateFlags ( ) ;
@ -52,6 +53,8 @@ struct AnyConverterTest: TestSuite::Tester {
void validatePropagatePreprocess ( ) ;
void convert ( ) ;
void convertUnknownInput ( ) ;
void convertUnknownOutput ( ) ;
void convertNotSupported ( ) ;
void convertPreprocessNotSupported ( ) ;
void convertDebugInfoNotSupported ( ) ;
@ -68,8 +71,6 @@ struct AnyConverterTest: TestSuite::Tester {
void detectConvert ( ) ;
void detectConvertExplicitFormat ( ) ;
void unknown ( ) ;
/* Explicitly forbid system-wide plugin dependencies. Tests that need those
have their own manager . */
PluginManager : : Manager < AbstractConverter > _manager { " nonexistent " } ;
@ -100,6 +101,7 @@ constexpr struct {
AnyConverterTest : : AnyConverterTest ( ) {
addTests ( { & AnyConverterTest : : validate ,
& AnyConverterTest : : validateUnknown ,
& AnyConverterTest : : validateNotSupported ,
& AnyConverterTest : : validatePreprocessNotSupported ,
& AnyConverterTest : : validatePropagateFlags ,
@ -108,6 +110,8 @@ AnyConverterTest::AnyConverterTest() {
& AnyConverterTest : : validatePropagatePreprocess ,
& AnyConverterTest : : convert ,
& AnyConverterTest : : convertUnknownInput ,
& AnyConverterTest : : convertUnknownOutput ,
& AnyConverterTest : : convertNotSupported ,
& AnyConverterTest : : convertPreprocessNotSupported ,
& AnyConverterTest : : convertDebugInfoNotSupported ,
@ -129,8 +133,6 @@ AnyConverterTest::AnyConverterTest() {
addTests ( { & AnyConverterTest : : detectConvertExplicitFormat } ) ;
addTests ( { & AnyConverterTest : : unknown } ) ;
/* Load the plugin directly from the build tree. Otherwise it's static and
already loaded . */
# ifdef ANYSHADERCONVERTER_PLUGIN_FILENAME
@ -159,6 +161,16 @@ void AnyConverterTest::validate() {
std : : make_pair ( true , Utility : : formatString ( " WARNING: {}:10: 'reserved__identifier' : identifiers containing consecutive underscores ( \" __ \" ) are reserved " , filename ) ) ) ;
}
void AnyConverterTest : : validateUnknown ( ) {
Containers : : Pointer < AbstractConverter > converter = _manager . instantiate ( " AnyShaderConverter " ) ;
std : : ostringstream out ;
Error redirectError { & out } ;
CORRADE_COMPARE ( converter - > validateFile ( { } , " dead.cg " ) ,
std : : make_pair ( false , " " ) ) ;
CORRADE_COMPARE ( out . str ( ) , " ShaderTools::AnyConverter::validateFile(): cannot determine the format of dead.cg \n " ) ;
}
void AnyConverterTest : : validateNotSupported ( ) {
CORRADE_SKIP ( " No plugin that would support just validation exists. " ) ;
}
@ -310,6 +322,24 @@ void AnyConverterTest::convert() {
" WARNING: {}:10: 'reserved__identifier' : identifiers containing consecutive underscores ( \" __ \" ) are reserved \n " , inputFilename ) ) ;
}
void AnyConverterTest : : convertUnknownInput ( ) {
Containers : : Pointer < AbstractConverter > converter = _manager . instantiate ( " AnyShaderConverter " ) ;
std : : ostringstream out ;
Error redirectError { & out } ;
CORRADE_VERIFY ( ! converter - > convertFileToFile ( { } , " dead.cg " , " whatever.osl " ) ) ;
CORRADE_COMPARE ( out . str ( ) , " ShaderTools::AnyConverter::convertFileToFile(): cannot determine the format of dead.cg \n " ) ;
}
void AnyConverterTest : : convertUnknownOutput ( ) {
Containers : : Pointer < AbstractConverter > converter = _manager . instantiate ( " AnyShaderConverter " ) ;
std : : ostringstream out ;
Error redirectError { & out } ;
CORRADE_VERIFY ( ! converter - > convertFileToFile ( { } , " file.spv " , " whatever.osl " ) ) ;
CORRADE_COMPARE ( out . str ( ) , " ShaderTools::AnyConverter::convertFileToFile(): cannot determine the format of whatever.osl \n " ) ;
}
void AnyConverterTest : : convertNotSupported ( ) {
CORRADE_SKIP ( " No plugin that would support just conversion exists. " ) ;
}
@ -635,16 +665,6 @@ void AnyConverterTest::detectConvertExplicitFormat() {
# endif
}
void AnyConverterTest : : unknown ( ) {
std : : ostringstream output ;
Error redirectError { & output } ;
Containers : : Pointer < AbstractConverter > converter = _manager . instantiate ( " AnyShaderConverter " ) ;
CORRADE_COMPARE ( converter - > validateFile ( { } , " dead.cg " ) ,
std : : make_pair ( false , " " ) ) ;
CORRADE_COMPARE ( output . str ( ) , " ShaderTools::AnyConverter::validateFile(): cannot determine the format of dead.cg \n " ) ;
}
} } } }
CORRADE_TEST_MAIN ( Magnum : : ShaderTools : : Test : : AnyConverterTest )