mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Merge branch 'purpleKarrot-develop' into develop
This commit is contained in:
commit
1ef7f0a847
53
.travis.yml
53
.travis.yml
@ -2,39 +2,46 @@ language: cpp
|
|||||||
|
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
|
- osx
|
||||||
|
|
||||||
compiler:
|
compiler:
|
||||||
# - clang # disabled clang due to missing libc++
|
- clang
|
||||||
- gcc
|
- gcc
|
||||||
|
|
||||||
|
env:
|
||||||
|
- CONFIG=Release
|
||||||
|
- CONFIG=Debug
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
on_success: change
|
on_success: change
|
||||||
on_failure: always
|
on_failure: always
|
||||||
|
|
||||||
before_install:
|
|
||||||
# install boost 1.50 (headers only), travis currently offers 1.46 and 1.48
|
|
||||||
- wget http://sourceforge.net/projects/boost/files/boost/1.50.0/boost_1_50_0.tar.bz2/download -O /tmp/boost.tar.bz2
|
|
||||||
- mkdir -p temp
|
|
||||||
- cd temp
|
|
||||||
- tar jxf /tmp/boost.tar.bz2 boost_1_50_0/boost # extract headers only
|
|
||||||
- sudo mkdir -p /usr/local/include/
|
|
||||||
- sudo ln -s $PWD/boost_1_50_0/boost /usr/local/include
|
|
||||||
- cd ..
|
|
||||||
#install g++-4.8
|
|
||||||
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
|
||||||
- sudo apt-get update
|
|
||||||
- if [ "$CXX" = "g++" ]; then sudo apt-get install g++-4.8; fi
|
|
||||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- "mkdir -p $TRAVIS_BUILD_DIR/build/scripts"
|
- CMAKE_VERSION_MM=3.2
|
||||||
- "cd $TRAVIS_BUILD_DIR/build/scripts"
|
- CMAKE_VERSION_FULL=$CMAKE_VERSION_MM.2
|
||||||
- "cmake $TRAVIS_BUILD_DIR"
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||||
|
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||||
|
&& sudo add-apt-repository -y ppa:apokluda/boost1.53
|
||||||
|
&& sudo apt-get update -qq
|
||||||
|
&& sudo apt-get install -qq g++-4.8 libboost1.53-dev --no-install-recommends
|
||||||
|
&& sudo update-alternatives --quiet --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.6
|
||||||
|
&& sudo update-alternatives --quiet --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.8
|
||||||
|
&& sudo update-alternatives --quiet --set gcc /usr/bin/gcc-4.8
|
||||||
|
&& wget http://www.cmake.org/files/v${CMAKE_VERSION_MM}/cmake-${CMAKE_VERSION_FULL}-Linux-x86_64.sh
|
||||||
|
&& sudo sh cmake-${CMAKE_VERSION_FULL}-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir;
|
||||||
|
fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install boost cmake; fi
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- mkdir build
|
||||||
|
- cd build
|
||||||
|
- if [[ "$CXX" = "g++" && "$CONFIG" = "Debug" ]]; then export CXXFLAGS="--coverage"; fi
|
||||||
|
- cmake .. -DCMAKE_BUILD_TYPE=$CONFIG
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- "cd $TRAVIS_BUILD_DIR/build/scripts"
|
- cmake --build . --config $CONFIG
|
||||||
- "make -j3"
|
- ctest --output-on-failure
|
||||||
# test compile-time constraints
|
|
||||||
- "make test_sqlpp_constraints"
|
|
||||||
|
|
||||||
|
after_script:
|
||||||
|
- ../coveralls
|
||||||
|
@ -22,25 +22,21 @@
|
|||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
||||||
|
project(sqlpp11 VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
# Cygwin does not define WIN32 and warn if not use with this flag
|
|
||||||
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
|
|
||||||
|
|
||||||
project (sqlpp11)
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
message(STATUS "Using ${CMAKE_CXX_COMPILER} (compiler id: ${CMAKE_CXX_COMPILER_ID})")
|
add_library(sqlpp11 INTERFACE)
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall ${CMAKE_CXX_FLAGS}")
|
target_include_directories(sqlpp11 INTERFACE
|
||||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
$<BUILD_INTERFACE:${sqlpp11_SOURCE_DIR}/include>
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}")
|
)
|
||||||
endif ()
|
|
||||||
set(CMAKE_CXX_FLAGS "-Wconversion -Wpedantic -Wshadow ${CMAKE_CXX_FLAGS}")
|
target_compile_features(sqlpp11 INTERFACE
|
||||||
|
cxx_variadic_templates
|
||||||
|
)
|
||||||
|
|
||||||
set(include_dir "${PROJECT_SOURCE_DIR}/include")
|
|
||||||
file(GLOB_RECURSE sqlpp_headers "${include_dir}/*.h")
|
|
||||||
include_directories("${include_dir}")
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
add_subdirectory(test_constraints)
|
add_subdirectory(test_constraints)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
|
1
CREDITS
1
CREDITS
@ -6,6 +6,7 @@ This library evolved through several stages and would probably not exist without
|
|||||||
* Paul Körbitz: Feedback and extensions
|
* Paul Körbitz: Feedback and extensions
|
||||||
* Peter Knoblach: Initial ideas
|
* Peter Knoblach: Initial ideas
|
||||||
* Ulrich Küttler: Feedback and extensions
|
* Ulrich Küttler: Feedback and extensions
|
||||||
|
* Daniel Pfeifer: Buildsystem, Travis, Coveralls
|
||||||
|
|
||||||
|
|
||||||
* Metafeed GmbH: Production code using a forerunner version
|
* Metafeed GmbH: Production code using a forerunner version
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
sqlpp11
|
sqlpp11
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/purpleKarrot/sqlpp11.svg?branch=develop)](https://travis-ci.org/purpleKarrot/sqlpp11)
|
||||||
|
[![Coverage Status](https://coveralls.io/repos/purpleKarrot/sqlpp11/badge.svg?branch=develop)](https://coveralls.io/r/purpleKarrot/sqlpp11?branch=develop)
|
||||||
|
|
||||||
A type safe embedded domain specific language for SQL queries and results in C++
|
A type safe embedded domain specific language for SQL queries and results in C++
|
||||||
|
|
||||||
Extensive documentation is found in the wiki, https://github.com/rbock/sqlpp11/wiki
|
Extensive documentation is found in the wiki, https://github.com/rbock/sqlpp11/wiki
|
||||||
|
31
coveralls
Executable file
31
coveralls
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ 0 -eq $(find -iname *.gcda | wc -l) ]
|
||||||
|
then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
gcov --source-prefix ${TRAVIS_BUILD_DIR} --preserve-paths --relative-only $(find -iname *.gcda) 1>/dev/null || exit 0
|
||||||
|
|
||||||
|
cat >coverage.json <<EOF
|
||||||
|
{
|
||||||
|
"service_job_id": "${TRAVIS_JOB_ID}",
|
||||||
|
"service_name": "travis-ci",
|
||||||
|
"source_files": [
|
||||||
|
EOF
|
||||||
|
|
||||||
|
for file in include*.gcov
|
||||||
|
do
|
||||||
|
path=$(echo ${file} | sed -re 's%#%\/%g; s%.gcov$%%')
|
||||||
|
cat >>coverage.json <<EOF
|
||||||
|
{
|
||||||
|
"name": "${path}",
|
||||||
|
"source_digest": "$(md5sum ${TRAVIS_BUILD_DIR}/${path} | awk '{ print $1 }')",
|
||||||
|
"coverage": [$(tail -n +3 ${file} | cut -d ':' -f 1 | sed -re 's%^ +%%g; s%-%null%g; s%^[#=]+$%0%;' | tr $'\n' ',' | sed -re 's%,$%%')]
|
||||||
|
},
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
|
||||||
|
mv coverage.json coverage.json.tmp
|
||||||
|
cat >coverage.json <(head -n -1 coverage.json.tmp) <(echo -e " }\n ]\n}")
|
||||||
|
curl -F json_file=@coverage.json https://coveralls.io/api/v1/jobs
|
@ -1,23 +1,50 @@
|
|||||||
|
# Copyright (c) 2013-2015, Roland Bock
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
# are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
# other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
macro (build arg)
|
set(example_names
|
||||||
# Add headers to sources to enable file browsing in IDEs
|
#sample
|
||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../tests")
|
insert
|
||||||
add_executable("Sqlpp11Example${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_CURRENT_SOURCE_DIR}/../tests/MockDb.h" "${CMAKE_CURRENT_LIST_DIR}/Sample.h")
|
update
|
||||||
add_test("${arg}" "Sqlpp11Example${arg}")
|
remove
|
||||||
endmacro ()
|
select
|
||||||
|
)
|
||||||
|
|
||||||
#build(sample)
|
|
||||||
build(insert)
|
|
||||||
build(update)
|
|
||||||
build(remove)
|
|
||||||
build(select)
|
|
||||||
find_package(Boost 1.50)
|
find_package(Boost 1.50)
|
||||||
if(Boost_FOUND)
|
if(Boost_FOUND)
|
||||||
MESSAGE(${Boost_INCLUDE_DIRS})
|
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
build(ppgen)
|
list(APPEND example_names ppgen)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
create_test_sourcelist(example_sources example_main.cpp ${example_names})
|
||||||
|
add_executable(sqlpp11_examples ${example_sources})
|
||||||
|
target_link_libraries(sqlpp11_examples PRIVATE sqlpp11 sqlpp11_testing)
|
||||||
|
|
||||||
|
foreach(example IN LISTS example_names)
|
||||||
|
add_test(NAME sqlpp11.examples.${example}
|
||||||
|
COMMAND sqlpp11_examples ${example}
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
#find_package(PythonInterp REQUIRED)
|
#find_package(PythonInterp REQUIRED)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "MockDb.h"
|
#include "MockDb.h"
|
||||||
#include <sqlpp11/sqlpp11.h>
|
#include <sqlpp11/sqlpp11.h>
|
||||||
|
|
||||||
int main()
|
int insert(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db;
|
MockDb db;
|
||||||
|
|
||||||
@ -64,4 +64,5 @@ int main()
|
|||||||
pi.params.feature = true;
|
pi.params.feature = true;
|
||||||
|
|
||||||
db(pi);
|
db(pi);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ SQLPP_DECLARE_TABLE(
|
|||||||
(fatal, bool , SQLPP_NOT_NULL )
|
(fatal, bool , SQLPP_NOT_NULL )
|
||||||
)
|
)
|
||||||
|
|
||||||
int main()
|
int ppgen(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db;
|
MockDb db;
|
||||||
tab_person::tab_person p;
|
tab_person::tab_person p;
|
||||||
@ -97,4 +97,5 @@ int main()
|
|||||||
pi.params.feature = true;
|
pi.params.feature = true;
|
||||||
|
|
||||||
db(pi);
|
db(pi);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "MockDb.h"
|
#include "MockDb.h"
|
||||||
#include <sqlpp11/sqlpp11.h>
|
#include <sqlpp11/sqlpp11.h>
|
||||||
|
|
||||||
int main()
|
int remove(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db;
|
MockDb db;
|
||||||
|
|
||||||
@ -37,4 +37,5 @@ int main()
|
|||||||
db(remove_from(p)
|
db(remove_from(p)
|
||||||
.using_(p, q)
|
.using_(p, q)
|
||||||
.where(p.feature == q.id and q.fatal == true));
|
.where(p.feature == q.id and q.fatal == true));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
SQLPP_ALIAS_PROVIDER(cheesecake)
|
SQLPP_ALIAS_PROVIDER(cheesecake)
|
||||||
|
|
||||||
int main()
|
int select(int, char**)
|
||||||
{
|
{
|
||||||
static constexpr bool some_condition = true;
|
static constexpr bool some_condition = true;
|
||||||
static constexpr bool some_other_condition = false;
|
static constexpr bool some_other_condition = false;
|
||||||
@ -153,4 +153,5 @@ int main()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "MockDb.h"
|
#include "MockDb.h"
|
||||||
#include <sqlpp11/sqlpp11.h>
|
#include <sqlpp11/sqlpp11.h>
|
||||||
|
|
||||||
int main()
|
int update(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db;
|
MockDb db;
|
||||||
|
|
||||||
@ -35,4 +35,5 @@ int main()
|
|||||||
//test::TabFeature q;
|
//test::TabFeature q;
|
||||||
|
|
||||||
db(update(p).set(p.feature = 7).where(p.id == 23));
|
db(update(p).set(p.feature = 7).where(p.id == 23));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,40 @@
|
|||||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../tests")
|
# Copyright (c) 2013-2015, Roland Bock
|
||||||
|
# All rights reserved.
|
||||||
add_custom_target(test_sqlpp_constraints COMMAND true)
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
# are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
# other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
function(test_constraint name pattern)
|
function(test_constraint name pattern)
|
||||||
|
set(test sqlpp11.test_constraints.${name})
|
||||||
add_executable(
|
set(target sqlpp11_${name})
|
||||||
"${name}"
|
add_executable(${target} EXCLUDE_FROM_ALL ${name}.cpp)
|
||||||
EXCLUDE_FROM_ALL
|
target_link_libraries(${target} PRIVATE sqlpp11 sqlpp11_testing)
|
||||||
"${name}.cpp"
|
add_test(NAME ${test}
|
||||||
|
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${target}
|
||||||
)
|
)
|
||||||
|
set_property(TEST ${test} PROPERTY PASS_REGULAR_EXPRESSION ${pattern})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
add_custom_command(OUTPUT "${name}.out"
|
test_constraint(count_of_count "count\\(\\) cannot be used on an aggregate function")
|
||||||
COMMAND "${CMAKE_MAKE_PROGRAM}" "${name}" > "${CMAKE_CURRENT_BINARY_DIR}/${name}.out" 2>&1 || true
|
test_constraint(max_of_max "max\\(\\) cannot be used on an aggregate function")
|
||||||
COMMAND grep "${pattern}" "${CMAKE_CURRENT_BINARY_DIR}/${name}.out" > /dev/null
|
|
||||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.cpp"
|
|
||||||
COMMENT "${name}"
|
|
||||||
VERBATIM)
|
|
||||||
|
|
||||||
add_custom_target("test_${name}" DEPENDS "${name}.out" COMMAND true)
|
|
||||||
|
|
||||||
|
|
||||||
add_dependencies(test_sqlpp_constraints "test_${name}")
|
|
||||||
|
|
||||||
endfunction(test_constraint)
|
|
||||||
|
|
||||||
test_constraint(count_of_count "count() cannot be used on an aggregate function")
|
|
||||||
test_constraint(max_of_max "max() cannot be used on an aggregate function")
|
|
||||||
test_constraint(no_conversion_operator_if_null_not_trivial "int i = row.alpha")
|
test_constraint(no_conversion_operator_if_null_not_trivial "int i = row.alpha")
|
||||||
test_constraint(require_insert "required column is missing")
|
test_constraint(require_insert "required column is missing")
|
||||||
test_constraint(must_not_insert "one assignment is prohibited")
|
test_constraint(must_not_insert "one assignment is prohibited")
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <sqlpp11/sqlpp11.h>
|
#include <sqlpp11/sqlpp11.h>
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int BooleanExpression(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db = {};
|
MockDb db = {};
|
||||||
test::TabBar t;
|
test::TabBar t;
|
@ -1,25 +1,57 @@
|
|||||||
|
# Copyright (c) 2013-2015, Roland Bock
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
# are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# Redistributions of source code must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
# other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
macro (build_and_run arg)
|
add_library(sqlpp11_testing INTERFACE)
|
||||||
# Add headers to sources to enable file browsing in IDEs
|
target_include_directories(sqlpp11_testing INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
include_directories("${CMAKE_BINARY_DIR}/tests")
|
target_compile_options(sqlpp11_testing INTERFACE -Wall -Wextra -pedantic)
|
||||||
add_executable("${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_CURRENT_LIST_DIR}/Sample.h")
|
|
||||||
add_test("${arg}" "${CMAKE_BINARY_DIR}/tests/${arg}")
|
|
||||||
endmacro ()
|
|
||||||
|
|
||||||
build_and_run(BooleanExpressionTest)
|
set(test_names
|
||||||
build_and_run(CustomQueryTest)
|
BooleanExpression
|
||||||
build_and_run(InterpretTest)
|
CustomQuery
|
||||||
build_and_run(InsertTest)
|
Interpret
|
||||||
build_and_run(RemoveTest)
|
Insert
|
||||||
build_and_run(UpdateTest)
|
Remove
|
||||||
build_and_run(SelectTest)
|
Update
|
||||||
build_and_run(SelectTypeTest)
|
Select
|
||||||
build_and_run(FunctionTest)
|
SelectType
|
||||||
build_and_run(PreparedTest)
|
Function
|
||||||
build_and_run(Minimalistic)
|
Prepared
|
||||||
build_and_run(ResultTest)
|
Minimalistic
|
||||||
build_and_run(UnionTest)
|
Result
|
||||||
build_and_run(WithTest)
|
Union
|
||||||
|
With
|
||||||
|
)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
foreach(test IN LISTS test_names)
|
||||||
|
add_test(NAME sqlpp11.tests.${test}
|
||||||
|
COMMAND sqlpp11_tests ${test}
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# if you want to use the generator, you can do something like this:
|
# if you want to use the generator, you can do something like this:
|
||||||
#find_package(PythonInterp REQUIRED)
|
#find_package(PythonInterp REQUIRED)
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <sqlpp11/sqlpp11.h>
|
#include <sqlpp11/sqlpp11.h>
|
||||||
#include <sqlpp11/custom_query.h>
|
#include <sqlpp11/custom_query.h>
|
||||||
|
|
||||||
int main()
|
int CustomQuery(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db = {};
|
MockDb db = {};
|
||||||
MockDb::_serializer_context_t printer;
|
MockDb::_serializer_context_t printer;
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
SQLPP_ALIAS_PROVIDER(kaesekuchen)
|
SQLPP_ALIAS_PROVIDER(kaesekuchen)
|
||||||
|
|
||||||
int main()
|
int Function(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db = {};
|
MockDb db = {};
|
||||||
test::TabFoo f;
|
test::TabFoo f;
|
@ -31,7 +31,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int Insert(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db;
|
MockDb db;
|
||||||
MockDb::_serializer_context_t printer;
|
MockDb::_serializer_context_t printer;
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main()
|
int Interpret(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db = {};
|
MockDb db = {};
|
||||||
MockDb::_serializer_context_t printer;
|
MockDb::_serializer_context_t printer;
|
@ -1,5 +1,6 @@
|
|||||||
#include <sqlpp11/sqlpp11.h>
|
#include <sqlpp11/sqlpp11.h>
|
||||||
|
|
||||||
int main()
|
int Minimalistic(int, char**)
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <sqlpp11/functions.h>
|
#include <sqlpp11/functions.h>
|
||||||
#include <sqlpp11/select.h>
|
#include <sqlpp11/select.h>
|
||||||
|
|
||||||
int main()
|
int Prepared(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db = {};
|
MockDb db = {};
|
||||||
//test::TabFoo f;
|
//test::TabFoo f;
|
@ -30,7 +30,7 @@
|
|||||||
#include "is_regular.h"
|
#include "is_regular.h"
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int Remove(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db;
|
MockDb db;
|
||||||
MockDb::_serializer_context_t printer;
|
MockDb::_serializer_context_t printer;
|
@ -32,7 +32,7 @@
|
|||||||
static_assert(not sqlpp::enforce_null_result_treatment_t<MockDb>::value, "MockDb interprets NULL as trivial");
|
static_assert(not sqlpp::enforce_null_result_treatment_t<MockDb>::value, "MockDb interprets NULL as trivial");
|
||||||
static_assert(sqlpp::enforce_null_result_treatment_t<EnforceDb>::value, "MockDb does not interpret NULL as trivial");
|
static_assert(sqlpp::enforce_null_result_treatment_t<EnforceDb>::value, "MockDb does not interpret NULL as trivial");
|
||||||
|
|
||||||
int main()
|
int Result(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db = {};
|
MockDb db = {};
|
||||||
EnforceDb edb {};
|
EnforceDb edb {};
|
@ -43,7 +43,7 @@ int64_t getColumn(Db&& db, const Column& column)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int Select(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db = {};
|
MockDb db = {};
|
||||||
MockDb::_serializer_context_t printer;
|
MockDb::_serializer_context_t printer;
|
@ -41,7 +41,7 @@ namespace alias
|
|||||||
SQLPP_ALIAS_PROVIDER(right)
|
SQLPP_ALIAS_PROVIDER(right)
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int SelectType(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db = {};
|
MockDb db = {};
|
||||||
MockDb::_serializer_context_t printer;
|
MockDb::_serializer_context_t printer;
|
@ -29,7 +29,7 @@
|
|||||||
#include <sqlpp11/alias_provider.h>
|
#include <sqlpp11/alias_provider.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main()
|
int Union(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db;
|
MockDb db;
|
||||||
MockDb::_serializer_context_t printer;
|
MockDb::_serializer_context_t printer;
|
@ -29,7 +29,7 @@
|
|||||||
#include "MockDb.h"
|
#include "MockDb.h"
|
||||||
#include "is_regular.h"
|
#include "is_regular.h"
|
||||||
|
|
||||||
int main()
|
int Update(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db;
|
MockDb db;
|
||||||
MockDb::_serializer_context_t printer;
|
MockDb::_serializer_context_t printer;
|
@ -29,7 +29,7 @@
|
|||||||
#include <sqlpp11/alias_provider.h>
|
#include <sqlpp11/alias_provider.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main()
|
int With(int, char**)
|
||||||
{
|
{
|
||||||
MockDb db;
|
MockDb db;
|
||||||
MockDb::_serializer_context_t printer;
|
MockDb::_serializer_context_t printer;
|
Loading…
Reference in New Issue
Block a user