Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate qt tests #12

Merged
merged 3 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Changed
- Deprecate submodules in favor of FetchContent API (cmake >3.14)
- Migrate qmake examples to cmake
- Migrate qmake examples and tests to cmake
- Update json to `v3.9.1` and replace implicit conversions


Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cmake_minimum_required( VERSION 3.14 FATAL_ERROR )

project(
vivid
project( vivid
VERSION 2.2.2
DESCRIPTION "A simple-to-use cpp color library"
HOMEPAGE_URL "https://github.com/gurki/vivid"
Expand Down
28 changes: 19 additions & 9 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
cmake_minimum_required( VERSION 3.14 FATAL_ERROR )

project( vivid_examples
VERSION 2.0.0
LANGUAGES CXX
)

add_executable( vivid_basics basics.cpp )
target_link_libraries( vivid_basics PRIVATE vivid )
add_executable( ${PROJECT_NAME}_basics basics.cpp )
target_link_libraries( ${PROJECT_NAME}_basics PRIVATE vivid )

add_executable( vivid_strong_types strong_types.cpp )
target_link_libraries( vivid_strong_types PRIVATE vivid )
add_executable( ${PROJECT_NAME}_strong_types strong_types.cpp )
target_link_libraries( ${PROJECT_NAME}_strong_types PRIVATE vivid )


find_package( Qt5 COMPONENTS Core Gui REQUIRED )
# examples with qt dependency (QImage, QColor)

add_executable( vivid_advanced advanced.cpp )
target_link_libraries( vivid_advanced PUBLIC Qt5::Core Qt5::Gui vivid )
find_package( Qt5 COMPONENTS Core Gui QUIET )

add_executable( vivid_convert_maps convert_maps.cpp )
target_link_libraries( vivid_convert_maps PUBLIC Qt5::Core Qt5::Gui vivid )
if ( Qt5_FOUND )

add_executable( ${PROJECT_NAME}_advanced advanced.cpp )
target_link_libraries( ${PROJECT_NAME}_advanced PUBLIC Qt5::Core Qt5::Gui vivid )

add_executable( ${PROJECT_NAME}_convert_maps convert_maps.cpp )
target_link_libraries( ${PROJECT_NAME}_convert_maps PUBLIC Qt5::Core Qt5::Gui vivid )

endif()
49 changes: 37 additions & 12 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
cmake_minimum_required( VERSION 3.8 )
project( vivid_tests VERSION 1.0.0 LANGUAGES CXX )
cmake_minimum_required( VERSION 3.14 FATAL_ERROR )

add_executable( vivid_tests
main.cpp
project( vivid_tests
VERSION 1.1.0
LANGUAGES CXX
)

find_package( Qt5 COMPONENTS Core Gui QUIET )

set( SOURCES
test_main.cpp
test_conversion_manual.cpp
test_profiles.cpp
# test_conversion_fuzzy.cpp # requires Qt
)

target_include_directories( vivid_tests
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
set( DEPENDENCIES vivid )

if ( Qt5_FOUND )

set( SOURCES
${SOURCES}
test_conversion_fuzzy.cpp
)

target_link_libraries( vivid_tests
PRIVATE
vivid::vivid
set( DEPENDENCIES
${DEPENDENCIES}
Qt5::Core
Qt5::Gui
)

endif()


add_executable( ${PROJECT_NAME} ${SOURCES} )

target_include_directories( ${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries( ${PROJECT_NAME}
PRIVATE
${DEPENDENCIES}
)
18 changes: 9 additions & 9 deletions tests/test_conversion_manual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ TEST_CASE( "Manual Conversions", "[conversions]" )
},
{
{ 1.f, 0.f, 0.f },
{ 0.412456, 0.212673, 0.019334 },
{ 53.2408, 80.0925, 67.2032 },
{ 53.2408, 104.5518, 39.9990 }
{ 0.412456f, 0.212673f, 0.019334f },
{ 53.2408f, 80.0925f, 67.2032f },
{ 53.2408f, 104.5518f, 39.9990f }
},
{
{ 0.f, 1.f, 0.f },
Expand Down Expand Up @@ -71,15 +71,15 @@ TEST_CASE( "Manual Conversions", "[conversions]" )
},
{
{ 0.7f, 0.3f, 0.3f },
{ 0.224179, 0.152938, 0.086990 },
{ 46.0340, 41.5389, 20.8161 },
{ 46.0340, 46.4628, 26.6165 }
{ 0.224179f, 0.152938f, 0.086990f },
{ 46.0340f, 41.5389f, 20.8161f },
{ 46.0340f, 46.4628f, 26.6165f }
},
{
{ 0.1f, 0.6f, 0.4f },
{ 0.142013f, 0.239531f, 0.164427 },
{ 56.0408f, -45.2026f, 17.7037 },
{ 56.0408f, 48.5459, 158.6121 }
{ 0.142013f, 0.239531f, 0.164427f },
{ 56.0408f, -45.2026f, 17.7037f },
{ 56.0408f, 48.5459f, 158.6121f }
}
};

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inline float randf( const float from = 0.f, const float to = 1.f )
static std::random_device rd;
static std::mt19937 mt( rd() );

std::uniform_real_distribution<> dist( from, to );
std::uniform_real_distribution<float> dist( from, to );
return dist( mt );
};

Expand All @@ -19,7 +19,7 @@ inline int randi( const int from = 0, const int to = 255 )
static std::random_device rd;
static std::mt19937 mt( rd() );

std::uniform_int_distribution<> dist( from, to );
std::uniform_int_distribution<int> dist( from, to );
return dist( mt );
};

Expand Down
20 changes: 0 additions & 20 deletions tests/vivid-tests.pro

This file was deleted.