Make test/FormatTraits.cpp valid for C++11.

This commit is contained in:
asuessenbach 2022-03-07 09:57:08 +01:00
parent 1f697d86cb
commit 7e6083e5b2
2 changed files with 30 additions and 16 deletions

View File

@ -14,24 +14,22 @@
cmake_minimum_required(VERSION 3.2)
if (NOT TESTS_BUILD_ONLY_DYNAMIC)
project(FormatTraits)
project(FormatTraits)
set(HEADERS
)
set(HEADERS
)
set(SOURCES
FormatTraits.cpp
)
set(SOURCES
FormatTraits.cpp
)
source_group(headers FILES ${HEADERS})
source_group(sources FILES ${SOURCES})
source_group(headers FILES ${HEADERS})
source_group(sources FILES ${SOURCES})
add_executable(FormatTraits
${HEADERS}
${SOURCES}
)
add_executable(FormatTraits
${HEADERS}
${SOURCES}
)
set_target_properties(FormatTraits PROPERTIES FOLDER "Tests")
target_link_libraries(FormatTraits "${Vulkan_LIBRARIES}")
endif()
set_target_properties(FormatTraits PROPERTIES FOLDER "Tests")
target_link_libraries(FormatTraits "${Vulkan_LIBRARIES}")

View File

@ -19,7 +19,11 @@
int main( int /*argc*/, char ** /*argv*/ )
{
#if VULKAN_HPP_CPP_VERSION < 14
assert( vk::blockSize( vk::Format::eR4G4UnormPack8 ) == 1 );
#else
static_assert( vk::blockSize( vk::Format::eR4G4UnormPack8 ) == 1, "Wrong blocksize !" );
#endif
vk::Format format = vk::Format::eR4G4UnormPack8;
if ( vk::texelsPerBlock( format ) == 1 )
@ -35,7 +39,11 @@ int main( int /*argc*/, char ** /*argv*/ )
format = vk::Format::eR4G4UnormPack8;
}
#if VULKAN_HPP_CPP_VERSION < 14
assert( vk::isCompressed( vk::Format::eBc1RgbSrgbBlock ) );
#else
static_assert( vk::isCompressed( vk::Format::eBc1RgbSrgbBlock ), "IsCompressed ?" );
#endif
assert( vk::packed( format ) == 8 );
@ -45,7 +53,11 @@ int main( int /*argc*/, char ** /*argv*/ )
}
constexpr vk::Format constFormat = vk::Format::eR4G4UnormPack8;
#if VULKAN_HPP_CPP_VERSION < 14
assert( vk::componentBits( constFormat, 1 ) == 4 );
#else
static_assert( vk::componentBits( constFormat, 1 ) == 4, "Wrong component bits !" );
#endif
assert( vk::componentCount( constFormat ) == 2 );
if ( strcmp( vk::componentName( constFormat, 0 ), "R" ) == 0 )
@ -55,7 +67,11 @@ int main( int /*argc*/, char ** /*argv*/ )
assert( std::string( vk::componentNumericFormat( constFormat, 1 ) ) == "UNORM" );
#if VULKAN_HPP_CPP_VERSION < 14
assert( vk::componentPlaneIndex( constFormat, 8 ) == 0 );
#else
static_assert( vk::componentPlaneIndex( constFormat, 8 ) == 0, "Hoo" );
#endif
if ( vk::planeCount( format ) != 1 )
{