diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fdf2415..550bce73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,6 +156,4 @@ install( ### Tests if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests) - add_subdirectory(test_types) - add_subdirectory(test_scripts) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b5d74b47..a2a481da 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -35,3 +35,4 @@ if(SQLITE3_CONNECTOR OR SQLCIPHER_CONNECTOR) add_subdirectory(sqlite3) endif() +add_subdirectory(scripts) diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index df5acca7..ee89b41e 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -25,5 +25,6 @@ add_subdirectory(usage) add_subdirectory(serialize) add_subdirectory(constraints) add_subdirectory(static_asserts) +add_subdirectory(types) diff --git a/tests/core/constraints/CMakeLists.txt b/tests/core/constraints/CMakeLists.txt index f3d9ed61..9f8ef69d 100644 --- a/tests/core/constraints/CMakeLists.txt +++ b/tests/core/constraints/CMakeLists.txt @@ -23,7 +23,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function(test_constraint name pattern) - set(test sqlpp11.test_constraints.${name}) + set(test sqlpp11.core.constraints.${name}) set(target sqlpp11_${name}) add_executable(${target} EXCLUDE_FROM_ALL ${name}.cpp) target_link_libraries(${target} PRIVATE sqlpp11 sqlpp11_testing) @@ -36,7 +36,7 @@ function(test_constraint name pattern) set_property(TARGET ${target} PROPERTY CXX_STANDARD ${SQLPP11_TESTS_CXX_STD}) set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED yes) set_property(TARGET ${target} PROPERTY CXX_EXTENSIONS no) - endif() + endif() endfunction() # Compiling these is required to fail (testing some static_assert) diff --git a/tests/core/serialize/CMakeLists.txt b/tests/core/serialize/CMakeLists.txt index 8c6d4e45..ef17916f 100644 --- a/tests/core/serialize/CMakeLists.txt +++ b/tests/core/serialize/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2017, Roland Bock +# Copyright (c) 2013-2021, Roland Bock # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, @@ -22,7 +22,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -set(test_serializer_names +set(test_names As Blob CustomQuery @@ -38,9 +38,9 @@ set(test_serializer_names ParameterizedVerbatim ) -create_test_sourcelist(test_serializer_sources test_serializer_main.cpp ${test_serializer_names}) -add_executable(sqlpp11_test_serializer ${test_serializer_sources}) -target_link_libraries(sqlpp11_test_serializer PRIVATE sqlpp11 sqlpp11_testing) +create_test_sourcelist(test_sources test_serializer_main.cpp ${test_names}) +add_executable(sqlpp11_core_serialize ${test_sources}) +target_link_libraries(sqlpp11_core_serialize PRIVATE sqlpp11 sqlpp11_testing) # conditionally bump to a higher C++ standard to test compatibility if (SQLPP11_TESTS_CXX_STD) @@ -49,9 +49,9 @@ if (SQLPP11_TESTS_CXX_STD) set_property(TARGET sqlpp11_test_serializer PROPERTY CXX_EXTENSIONS no) endif() -foreach(test_serializer IN LISTS test_serializer_names) - add_test(NAME sqlpp11.test_serializer.${test_serializer} - COMMAND sqlpp11_test_serializer ${test_serializer} +foreach(test IN LISTS test_names) + add_test(NAME sqlpp11.core.serialize.${test} + COMMAND sqlpp11_core_serialize ${test} ) endforeach() diff --git a/test_types/CMakeLists.txt b/tests/core/types/CMakeLists.txt similarity index 99% rename from test_types/CMakeLists.txt rename to tests/core/types/CMakeLists.txt index 1d310542..29aee3a9 100644 --- a/test_types/CMakeLists.txt +++ b/tests/core/types/CMakeLists.txt @@ -31,7 +31,7 @@ function(test_compile name) set_property(TARGET sqlpp11_${name} PROPERTY CXX_STANDARD ${SQLPP11_TESTS_CXX_STD}) set_property(TARGET sqlpp11_${name} PROPERTY CXX_STANDARD_REQUIRED yes) set_property(TARGET sqlpp11_${name} PROPERTY CXX_EXTENSIONS no) - endif() + endif() endfunction() test_compile(result_row) diff --git a/test_types/result_row.cpp b/tests/core/types/result_row.cpp similarity index 100% rename from test_types/result_row.cpp rename to tests/core/types/result_row.cpp diff --git a/tests/core/usage/CMakeLists.txt b/tests/core/usage/CMakeLists.txt index cdabd006..b885e04b 100644 --- a/tests/core/usage/CMakeLists.txt +++ b/tests/core/usage/CMakeLists.txt @@ -55,18 +55,18 @@ endif() create_test_sourcelist(test_sources test_main.cpp ${test_names}) -add_executable(sqlpp11_tests ${test_sources}) -target_link_libraries(sqlpp11_tests PRIVATE sqlpp11 sqlpp11_testing) +add_executable(sqlpp11_core_tests ${test_sources}) +target_link_libraries(sqlpp11_core_tests PRIVATE sqlpp11 sqlpp11_testing) # conditionally bump to a higher C++ standard to test compatibility if (SQLPP11_TESTS_CXX_STD) - set_property(TARGET sqlpp11_tests PROPERTY CXX_STANDARD ${SQLPP11_TESTS_CXX_STD}) - set_property(TARGET sqlpp11_tests PROPERTY CXX_STANDARD_REQUIRED yes) - set_property(TARGET sqlpp11_tests PROPERTY CXX_EXTENSIONS no) + set_property(TARGET sqlpp11_core_tests PROPERTY CXX_STANDARD ${SQLPP11_TESTS_CXX_STD}) + set_property(TARGET sqlpp11_core_tests PROPERTY CXX_STANDARD_REQUIRED yes) + set_property(TARGET sqlpp11_core_tests PROPERTY CXX_EXTENSIONS no) endif() foreach(test IN LISTS test_names) - add_test(NAME sqlpp11.tests.${test} - COMMAND sqlpp11_tests ${test} + add_test(NAME sqlpp11.core.usage.${test} + COMMAND sqlpp11_core_tests ${test} ) endforeach() diff --git a/tests/mysql/usage/CMakeLists.txt b/tests/mysql/usage/CMakeLists.txt index ffa394db..7b4ecb4f 100644 --- a/tests/mysql/usage/CMakeLists.txt +++ b/tests/mysql/usage/CMakeLists.txt @@ -61,7 +61,7 @@ set_property(TARGET sqlpp11_mysql_tests PROPERTY CXX_STANDARD_REQUIRED yes) endif() foreach(test IN LISTS test_names) - add_test(NAME sqlpp11.mysql.tests.${test} + add_test(NAME sqlpp11.mysql.usage.${test} COMMAND sqlpp11_mysql_tests ${test} ) endforeach() diff --git a/test_scripts/CMakeLists.txt b/tests/scripts/CMakeLists.txt similarity index 56% rename from test_scripts/CMakeLists.txt rename to tests/scripts/CMakeLists.txt index 0a8c2b46..0b5b9090 100644 --- a/test_scripts/CMakeLists.txt +++ b/tests/scripts/CMakeLists.txt @@ -27,56 +27,56 @@ include(FindPython3) if (${Python3_Interpreter_FOUND}) execute_process( COMMAND ${Python3_EXECUTABLE} -c "import pyparsing" - RESULT_VARIABLE PythonRESULT - OUTPUT_VARIABLE PythonOUTPUT + RESULT_VARIABLE PythonRESULT + OUTPUT_VARIABLE PythonOUTPUT ERROR_VARIABLE PythonERROR ) - if (${PythonRESULT}) + if (${PythonRESULT}) message(WARNING "Pyparsing is not installed. Disabling ddl2cpp tests") - else() + else() message(STATUS "Pyparsing is installed: Enabling ddl2cpp tests.") - add_test(NAME sqlpp11.test.ddl2cpp.bad_will_fail - COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../scripts/ddl2cpp" -fail-on-parse - "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_bad.sql" - "${CMAKE_CURRENT_BINARY_DIR}/fail" - test) - set_tests_properties(sqlpp11.test.ddl2cpp.bad_will_fail PROPERTIES WILL_FAIL 1) + add_test(NAME sqlpp11.scripts.ddl2cpp.bad_will_fail + COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../../scripts/ddl2cpp" -fail-on-parse + "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_bad.sql" + "${CMAKE_CURRENT_BINARY_DIR}/fail" + test) + set_tests_properties(sqlpp11.scripts.ddl2cpp.bad_will_fail PROPERTIES WILL_FAIL 1) - add_test(NAME sqlpp11.test.ddl2cpp.bad_has_parse_error - COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../scripts/ddl2cpp" -fail-on-parse - "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_bad.sql" - "${CMAKE_CURRENT_BINARY_DIR}/fail" - test) - set_tests_properties(sqlpp11.test.ddl2cpp.bad_has_parse_error PROPERTIES PASS_REGULAR_EXPRESSION "Parsing error,.*") + add_test(NAME sqlpp11.scripts.ddl2cpp.bad_has_parse_error + COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../../scripts/ddl2cpp" -fail-on-parse + "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_bad.sql" + "${CMAKE_CURRENT_BINARY_DIR}/fail" + test) + set_tests_properties(sqlpp11.scripts.ddl2cpp.bad_has_parse_error PROPERTIES PASS_REGULAR_EXPRESSION "Parsing error,.*") - add_test(NAME sqlpp11.test.ddl2cpp.good_succeeds - COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../scripts/ddl2cpp" -fail-on-parse - "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_good.sql" - "${CMAKE_CURRENT_BINARY_DIR}/fail" - test) + add_test(NAME sqlpp11.scripts.ddl2cpp.good_succeeds + COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../../scripts/ddl2cpp" -fail-on-parse + "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_good.sql" + "${CMAKE_CURRENT_BINARY_DIR}/fail" + test) foreach(sample_name sample sample_identity_naming) - set(sqlpp.test.generated.sample.include "${CMAKE_CURRENT_BINARY_DIR}/${sample_name}") + set(sqlpp.scripts.generated.sample.include "${CMAKE_CURRENT_BINARY_DIR}/${sample_name}") include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(use_identity_naming) if(sample_name STREQUAL "sample_identity_naming") set(use_identity_naming -identity-naming) endif() add_custom_command( - OUTPUT "${sqlpp.test.generated.sample.include}.h" - COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../scripts/ddl2cpp" + OUTPUT "${sqlpp.scripts.generated.sample.include}.h" + COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_LIST_DIR}/../../scripts/ddl2cpp" ${use_identity_naming} "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_good.sql" - "${sqlpp.test.generated.sample.include}" + "${sqlpp.scripts.generated.sample.include}" test DEPENDS "${CMAKE_CURRENT_LIST_DIR}/ddl2cpp_sample_good.sql" VERBATIM) - add_executable(sqlpp.test.compiled.${sample_name} ${sample_name}.cpp "${sqlpp.test.generated.sample.include}.h") - target_link_libraries(sqlpp.test.compiled.${sample_name} PRIVATE sqlpp11) + add_executable(sqlpp.scripts.compiled.${sample_name} ${sample_name}.cpp "${sqlpp.scripts.generated.sample.include}.h") + target_link_libraries(sqlpp.scripts.compiled.${sample_name} PRIVATE sqlpp11) endforeach() endif() diff --git a/test_scripts/ddl2cpp_sample_bad.sql b/tests/scripts/ddl2cpp_sample_bad.sql similarity index 100% rename from test_scripts/ddl2cpp_sample_bad.sql rename to tests/scripts/ddl2cpp_sample_bad.sql diff --git a/test_scripts/ddl2cpp_sample_good.sql b/tests/scripts/ddl2cpp_sample_good.sql similarity index 100% rename from test_scripts/ddl2cpp_sample_good.sql rename to tests/scripts/ddl2cpp_sample_good.sql diff --git a/test_scripts/sample.cpp b/tests/scripts/sample.cpp similarity index 100% rename from test_scripts/sample.cpp rename to tests/scripts/sample.cpp diff --git a/test_scripts/sample_identity_naming.cpp b/tests/scripts/sample_identity_naming.cpp similarity index 100% rename from test_scripts/sample_identity_naming.cpp rename to tests/scripts/sample_identity_naming.cpp diff --git a/tests/sqlite3/usage/CMakeLists.txt b/tests/sqlite3/usage/CMakeLists.txt index 66ec4351..7c45c0fc 100644 --- a/tests/sqlite3/usage/CMakeLists.txt +++ b/tests/sqlite3/usage/CMakeLists.txt @@ -62,7 +62,7 @@ if (SQLPP11_TESTS_CXX_STD) endif() foreach(test IN LISTS test_names) - add_test(NAME sqlpp11.sqlite3.tests.${test} + add_test(NAME sqlpp11.sqlite3.usage.${test} COMMAND sqlpp11_sqlite3_tests ${test} ) endforeach() diff --git a/tests/sqlite3/usage/Integral.cpp b/tests/sqlite3/usage/Integral.cpp index 8052cefd..6eba0b2a 100644 --- a/tests/sqlite3/usage/Integral.cpp +++ b/tests/sqlite3/usage/Integral.cpp @@ -107,7 +107,7 @@ int Integral(int, char*[]) require_equal(__LINE__, rows.front().unsignedValue.value(), uint64_t_value_unsupported); rows.pop_front(); - require_equal(__LINE__, rows.front().signedValue.value(), int64_t_value_min); + require_equal(__LINE__, rows.front().signedValue.value(), int64_t{}); require_equal(__LINE__, rows.front().unsignedValue.value(), size_t_value_max); rows.pop_front();