From 7e6083e5b2f83b613ff7f53e82920072c9998a38 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Mon, 7 Mar 2022 09:57:08 +0100 Subject: [PATCH] Make test/FormatTraits.cpp valid for C++11. --- tests/FormatTraits/CMakeLists.txt | 30 ++++++++++++++--------------- tests/FormatTraits/FormatTraits.cpp | 16 +++++++++++++++ 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/tests/FormatTraits/CMakeLists.txt b/tests/FormatTraits/CMakeLists.txt index 87c271d..cdba885 100644 --- a/tests/FormatTraits/CMakeLists.txt +++ b/tests/FormatTraits/CMakeLists.txt @@ -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() \ No newline at end of file +set_target_properties(FormatTraits PROPERTIES FOLDER "Tests") +target_link_libraries(FormatTraits "${Vulkan_LIBRARIES}") diff --git a/tests/FormatTraits/FormatTraits.cpp b/tests/FormatTraits/FormatTraits.cpp index 2b2082a..114f402 100644 --- a/tests/FormatTraits/FormatTraits.cpp +++ b/tests/FormatTraits/FormatTraits.cpp @@ -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 ) {