From 07cba89bfb81f5a0aff1beafff4bf834cff92540 Mon Sep 17 00:00:00 2001 From: vaijns Date: Sat, 7 Dec 2024 11:50:08 +0100 Subject: [PATCH] Add tests for CURRENT_* functions and remove parameter names in serialize() functions --- include/sqlpp11/current_date.h | 2 +- include/sqlpp11/current_time.h | 2 +- include/sqlpp11/current_timestamp.h | 2 +- tests/core/serialize/CMakeLists.txt | 3 ++ tests/core/serialize/CurrentDate.cpp | 34 +++++++++++++++++++++++ tests/core/serialize/CurrentTime.cpp | 34 +++++++++++++++++++++++ tests/core/serialize/CurrentTimestamp.cpp | 34 +++++++++++++++++++++++ 7 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 tests/core/serialize/CurrentDate.cpp create mode 100644 tests/core/serialize/CurrentTime.cpp create mode 100644 tests/core/serialize/CurrentTimestamp.cpp diff --git a/include/sqlpp11/current_date.h b/include/sqlpp11/current_date.h index 3d478516..9c74a4e8 100644 --- a/include/sqlpp11/current_date.h +++ b/include/sqlpp11/current_date.h @@ -74,7 +74,7 @@ namespace sqlpp }; template - Context& serialize(const current_date_t& t, Context& context) + Context& serialize(const current_date_t&, Context& context) { context << "CURRENT_DATE"; return context; diff --git a/include/sqlpp11/current_time.h b/include/sqlpp11/current_time.h index 43154a8f..2c4c5ecc 100644 --- a/include/sqlpp11/current_time.h +++ b/include/sqlpp11/current_time.h @@ -74,7 +74,7 @@ namespace sqlpp }; template - Context& serialize(const current_time_t& t, Context& context) + Context& serialize(const current_time_t&, Context& context) { context << "CURRENT_TIME"; return context; diff --git a/include/sqlpp11/current_timestamp.h b/include/sqlpp11/current_timestamp.h index 98db4a12..dee99e91 100644 --- a/include/sqlpp11/current_timestamp.h +++ b/include/sqlpp11/current_timestamp.h @@ -74,7 +74,7 @@ namespace sqlpp }; template - Context& serialize(const current_timestamp_t& t, Context& context) + Context& serialize(const current_timestamp_t&, Context& context) { context << "CURRENT_TIMESTAMP"; return context; diff --git a/tests/core/serialize/CMakeLists.txt b/tests/core/serialize/CMakeLists.txt index 51ed9757..05fa9915 100644 --- a/tests/core/serialize/CMakeLists.txt +++ b/tests/core/serialize/CMakeLists.txt @@ -51,6 +51,9 @@ set(test_files Upper.cpp Where.cpp ParameterizedVerbatim.cpp + CurrentTimestamp.cpp + CurrentTime.cpp + CurrentDate.cpp ) create_test_sourcelist(test_sources test_serializer_main.cpp ${test_files}) diff --git a/tests/core/serialize/CurrentDate.cpp b/tests/core/serialize/CurrentDate.cpp new file mode 100644 index 00000000..e98b0f2f --- /dev/null +++ b/tests/core/serialize/CurrentDate.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024, 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. + */ + +#include "compare.h" +#include + +int CurrentDate(int, char* []) +{ + compare(__LINE__, sqlpp::current_date, "CURRENT_DATE"); + + return 0; +} diff --git a/tests/core/serialize/CurrentTime.cpp b/tests/core/serialize/CurrentTime.cpp new file mode 100644 index 00000000..a5739d92 --- /dev/null +++ b/tests/core/serialize/CurrentTime.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024, 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. + */ + +#include "compare.h" +#include + +int CurrentTime(int, char* []) +{ + compare(__LINE__, sqlpp::current_time, "CURRENT_TIME"); + + return 0; +} diff --git a/tests/core/serialize/CurrentTimestamp.cpp b/tests/core/serialize/CurrentTimestamp.cpp new file mode 100644 index 00000000..f2b82e64 --- /dev/null +++ b/tests/core/serialize/CurrentTimestamp.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024, 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. + */ + +#include "compare.h" +#include + +int CurrentTimestamp(int, char* []) +{ + compare(__LINE__, sqlpp::current_timestamp, "CURRENT_TIMESTAMP"); + + return 0; +}