mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Added string_view tests and C++17 tests for travis
This commit is contained in:
parent
ac3a8290ff
commit
460557c6e0
@ -13,6 +13,7 @@ compiler:
|
||||
|
||||
env:
|
||||
- CONFIG=Release
|
||||
- CONFIG=Release TESTS_CXX_STD=17
|
||||
#- CONFIG=Debug
|
||||
|
||||
notifications:
|
||||
@ -40,7 +41,8 @@ before_script:
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=$CONFIG -DCMAKE_PREFIX_PATH=$PWD/../date
|
||||
|
||||
script:
|
||||
- cmake --build . --config $CONFIG
|
||||
- [[ -n "$TESTS_CXX_STD" ]] && ARGS="-DSQLPP11_TESTS_CXX_STD=$TESTS_CXX_STD"
|
||||
- cmake --build . --config $CONFIG $ARGS
|
||||
- ctest --output-on-failure
|
||||
|
||||
after_script:
|
||||
|
@ -31,6 +31,12 @@ function(test_constraint name pattern)
|
||||
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${target}
|
||||
)
|
||||
set_property(TEST ${test} PROPERTY PASS_REGULAR_EXPRESSION ${pattern})
|
||||
# conditionally bump to a higher C++ standard to test compatibility
|
||||
if (SQLPP11_TESTS_CXX_STD)
|
||||
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()
|
||||
endfunction()
|
||||
|
||||
# Compiling these is required to fail (testing some static_assert)
|
||||
|
@ -38,6 +38,13 @@ create_test_sourcelist(test_serializer_sources test_serializer_main.cpp ${test_s
|
||||
add_executable(sqlpp11_test_serializer ${test_serializer_sources})
|
||||
target_link_libraries(sqlpp11_test_serializer PRIVATE sqlpp11 sqlpp11_testing)
|
||||
|
||||
# conditionally bump to a higher C++ standard to test compatibility
|
||||
if (SQLPP11_TESTS_CXX_STD)
|
||||
set_property(TARGET sqlpp11_test_serializer PROPERTY CXX_STANDARD ${SQLPP11_TESTS_CXX_STD})
|
||||
set_property(TARGET sqlpp11_test_serializer PROPERTY CXX_STANDARD_REQUIRED yes)
|
||||
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}
|
||||
|
@ -45,6 +45,12 @@ int Insert(int, char* [])
|
||||
compare(__LINE__, insert_into(bar).default_values(), "INSERT INTO tab_bar DEFAULT VALUES");
|
||||
compare(__LINE__, insert_into(bar).set(bar.beta = "cheesecake", bar.gamma = true),
|
||||
"INSERT INTO tab_bar (beta,gamma) VALUES('cheesecake'," + getTrue() + ")");
|
||||
#if __cplusplus >= 201703L
|
||||
// string_view argument
|
||||
std::string_view cheeseCake = "cheesecake";
|
||||
compare(__LINE__, insert_into(bar).set(bar.beta = cheeseCake, bar.gamma = true),
|
||||
"INSERT INTO tab_bar (beta,gamma) VALUES('cheesecake'," + getTrue() + ")");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -62,6 +62,11 @@ int Where(int, char* [])
|
||||
compare(__LINE__, where(bar.gamma), " WHERE tab_bar.gamma");
|
||||
compare(__LINE__, where(bar.gamma == false), " WHERE (tab_bar.gamma=" + getFalse() + ")");
|
||||
compare(__LINE__, where(bar.beta == "SQL"), " WHERE (tab_bar.beta='SQL')");
|
||||
#if __cplusplus >= 201703L
|
||||
// string_view argument
|
||||
std::string_view sqlString = "SQL";
|
||||
compare(__LINE__, where(bar.beta == sqlString), " WHERE (tab_bar.beta='SQL')");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -26,6 +26,12 @@ function(test_compile name)
|
||||
set(target sqlpp11_assert_${name})
|
||||
add_executable(${target} ${name}.cpp)
|
||||
target_link_libraries(${target} PRIVATE sqlpp11 sqlpp11_testing)
|
||||
# conditionally bump to a higher C++ standard to test compatibility
|
||||
if (SQLPP11_TESTS_CXX_STD)
|
||||
set_property(TARGET sqlpp11_assert_${name} PROPERTY CXX_STANDARD ${SQLPP11_TESTS_CXX_STD})
|
||||
set_property(TARGET sqlpp11_assert_${name} PROPERTY CXX_STANDARD_REQUIRED yes)
|
||||
set_property(TARGET sqlpp11_assert_${name} PROPERTY CXX_EXTENSIONS no)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
test_compile(aggregates)
|
||||
|
@ -26,6 +26,12 @@ function(test_compile name)
|
||||
set(target sqlpp11_${name})
|
||||
add_executable(${target} ${name}.cpp)
|
||||
target_link_libraries(${target} PRIVATE sqlpp11 sqlpp11_testing)
|
||||
# conditionally bump to a higher C++ standard to test compatibility
|
||||
if (SQLPP11_TESTS_CXX_STD)
|
||||
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()
|
||||
endfunction()
|
||||
|
||||
test_compile(result_row)
|
||||
|
@ -57,6 +57,12 @@ 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)
|
||||
# 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)
|
||||
endif()
|
||||
|
||||
foreach(test IN LISTS test_names)
|
||||
add_test(NAME sqlpp11.tests.${test}
|
||||
|
Loading…
Reference in New Issue
Block a user