Commit Graph

40 Commits

Author SHA1 Message Date
Vadim Zeitlin
547a62eec1 Add fmt library as submodule and use it in the tests
Replace existing use of std::cout and std::cerr with fmt::print[ln]():
this is simpler and more convenient and also faster to compile.

Also configure all CI jobs to clone submodules, as fmt submodule is
required now.
2026-01-14 23:40:06 +01:00
Vadim Zeitlin
f7a1a05913 Use nullptr instead of NULL or 0
Run clang-tidy modernize-use-nullptr check on all files and manually
change the remaining NULLs skipped by it to nullptr.

Also use nullptr in the documentation.
2026-01-14 14:24:39 +01:00
Vadim Zeitlin
c35b1b6a77 Avoid disabling MSVC CRT security warnings globally
Use "_s" versions of the standard C functions if possible/simple to do
and disable deprecation warnings explicitly in a couple of places where
this could not be done instead of disabling them globally.

Also stop using strcpy() entirely and use strncpy() instead.

See #1268.
2025-06-08 02:49:21 +02:00
Vadim Zeitlin
20325f57c9 Add unit test to check loading backends dynamically
Ensure that loading backend dynamically, i.e. using their name, works.

This required adding a way to get this name from the test context.

See #1250.
2025-05-17 00:33:31 +02:00
Vadim Zeitlin
fb04446e35 Convert most HTTP links to HTTPS
No real changes, but it's not very serious to use HTTP links in 2025.
2025-03-04 18:03:53 +01:00
Vadim Zeitlin
0aa2c1f27b Get rid of "soci_use_common_tests" hack
This can be avoided by using a different base test context class for the
non-empty tests.
2024-11-06 14:54:37 +01:00
Vadim Zeitlin
b0ecbca57a Extract common tests in soci_tests_common library
This allows to compile them once, instead of doing it for every backend:
while this doesn't matter for the CI builds, recompiling common-tests.h
a dozen times enormously slowed down local builds using all backends.

Now it is compiled only once, as test-common.cpp, and all the other
tests (except for the "empty" one) just link with the resulting library.

Also extract some parts of this file into separate headers, that can be
included only by the tests that actually need them.

Note that the entire test-common.cpp probably ought to be split into
multiple files, to speed up its build too, but this can be done later.
2024-10-23 13:54:01 +02:00
Robert Adam
be4677149e Address review comments 2024-01-16 20:45:30 +01:00
Robert Adam
47d9068366 Special case data type for Oracle backend 2024-01-13 17:09:31 +01:00
Robert Adam
ae75990cb2 finalize common blob test & remove backend-specific ones 2024-01-13 16:46:31 +01:00
Robert Adam
761e35d286 Firebird: Fix failing common tests 2024-01-13 16:46:31 +01:00
Robert Adam
68033e037a Start implementing shared BLOB tests 2024-01-13 16:46:31 +01:00
Robert Adam
7fa93e8586 BLOB: Add default-constructed read tests 2024-01-13 16:46:31 +01:00
Lukas Zanner
826fa7753a Expose new db_type for dynamic type mapping 2023-08-13 17:26:15 +02:00
Lukas Zanner
88e2cb4ae5 Fix uint64 vector unit tests
Firebird and SQLite store UINT64_MAX incorrectly, leading to an incorrect
value ordering when retrieving sorted table contents.
2023-08-13 17:25:32 +02:00
Lukas Zanner
4c36213928 Remove unsigned type support checks in unit tests
Despite previously assumed and tested, most of the databases support
storing the various unsigned integer values. The checks for it in the
tests are therefore obsolete.
Only Firebird and SQLite seem to have a problem with storing UINT64_MAX.
The retrieval of it in a sorted result set with multiple other values
shows that the value is stored as a signed integer in the database.
2023-08-13 17:25:32 +02:00
Lukas Zanner
367c0c0341 Revert unnecessary changes in unit tests 2023-08-13 17:25:30 +02:00
Lukas Zanner
b56224e6a7 Update unit test of Firebird backend for complete integer type support 2023-08-13 17:25:27 +02:00
Vadim Zeitlin
6d5fd5a79f Upgrade CATCH header to v2
And update all uses of CHECK_THROWS_AS() to not use reference but the
expected exception type itself, as otherwise the code doesn't compile
any longer.
2022-12-25 23:27:51 +01:00
Robert Adam
2d37f99530 BLOB: Make [read|write]_from_start the default impl
The older read(...) and write(...) function, which take backend-specific
offsets rather than uniformly taken 0-based offsets (as is the case for
the *_from_start(...) functions), are now implemented in terms of their
*_from_start counterpart.

All test cases have been adapted to now prefer using the *_from_start
functions over the old counterparts.
2022-09-22 19:57:02 +02:00
Vadim Zeitlin
04c3daf8c3 Drop SOCI_OVERRIDE and use override keyword directly
We don't need the macro any longer now that we use C++14.
2022-09-18 17:28:57 +02:00
Vadim Zeitlin
fcd1eec279 Avoid g++-8 -Wcatch-value warnings in the tests
Catch soci_error (and std::bad_cast in one place) by reference rather
than by value to avoid slicing -- even if it doesn't matter in the test
code, it still provokes the new g++-8 warning about it.

See #640.
2018-05-20 16:04:22 +02:00
Mateusz Loskot
05ab0bcf6d Add SOCI_OVERRIDE macro as conditional C++11 override specifier
MSVC++ 1900+ always compile with C++11 mode enabled, so it should be
safe to selectively enable 'override'specifier for internal use.

It does not enable all C++11 features for SOCI and we still compile
with C++11 compilation mode SOCI_CXX_C11=OFF by default.

Refactoring performed with clang-tidy-4.0:

 cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DSOCI_CXX_C11=ON ..
 run-clang-tidy.py -clang-tidy-binary -header-filter='.*' \
                   -checks='-*,modernize-use-modernize' -fix
2017-09-24 23:05:06 +02:00
Vadim Zeitlin
bd236c8c8e Merge branch 'xml-firebird'
Closes #578.
2017-09-15 00:32:12 +02:00
Vadim Zeitlin
63bcc89440 Add workaround for empty strings being null in Oracle
Oracle historically treats empty VARCHAR[2] column values as nulls, so
we need to adjust the string length unit test to provide indicators when
retrieving the value of a possibly null string and use nvl() to compute
its length to make this test pass when using this backend.
2017-09-14 15:03:45 +02:00
Vadim Zeitlin
9943459f40 Add support for XML type to Firebird backend too
There is no real XML support in Firebird, so handle it in the same way
as CLOB -- this is the best that can be done with this database anyhow
and is much better than not supporting it at all.
2017-09-13 15:09:35 +02:00
Vadim Zeitlin
059faf5d96 Add CLOB support to Firebird backend
Reuse the existing BLOB support, however we now need to allocate a BLOB
inside firebird_standard_use_type_backend objects as, unlike when using
soci::blob objects, we don't have any way to associate backend-specific
data with the parameter otherwise.

This difference between CLOB and BLOB support is not ideal, but there
doesn't seem to be any way to avoid it.
2017-09-13 15:09:35 +02:00
Vadim Zeitlin
c6aef12b1e Add test checking string length when using bulk insert
This used to be broken, so add a test to check that it works after the
changes of the last commit and to avoid breaking it again.
2017-07-22 01:18:03 +02:00
Sergei Nikulov
b510e1a63d moved to latest Catch UT Framework (#544)
* Moved to latest Catch UT Framework
* Added -Wextra to gcc and clang
* Fixed discovered issues
2017-07-07 21:31:41 +03:00
Miha Ravselj
0a88814c29 Added Firebird specific test indicating BLOB write bug. 2017-03-01 21:25:41 +01:00
Miha Ravselj
274d08a736 Explicitly set character set in Firebird unit tests for CHAR(N).
Without an explicit "character set none", the default character set of the
database is used and if it is set to UTF-8 the values are padded incorrectly
resulting in the test failures.

See #356.
2015-07-15 04:07:11 +02:00
Miha Ravselj
7623f76fe1 More and better MSVC warnings fixes.
Fix warnings by changing the code whenever possible, in particular remove
firebird_rowid_backend class and src/backends/firebird/row-id.cpp file in
which it was defined entirely as it only resulted in "unreachable code"
warnings but was otherwise unused.

Also avoid implicit conversions by either using the correct types or by making
the casts explicit using static_cast<> in places where the casts are really
needed.

Add helpful SOCI_NOT_COPYABLE, SOCI_NOT_ASSIGNABLE and SOCI_UNUSED macros and
use them to suppress the corresponding warnings.

Finally, combine soci-config.h and soci-platform.h in a single file, always
include the latter as the first header and keep the former as a wrapper for
the latter just for compatibility.

Remove the MSVC "#pragma warning(disable: *)" as they are not needed any more.

Closes #355.
2015-07-15 03:37:25 +02:00
Benjamin Blundell
ffbfdc0ef5 Inlined the pragmas for the C++11 tests 2015-05-22 14:46:36 +01:00
Mateusz Loskot
7d7516d417 Add more qualifications uses of session class with namespace soci::session.
This should solve compilation errors on OSX where struct session defined in
global namespace in /usr/include/sys/proc.h conflicts with unqualified uses of
soci::session.
Fixes #340
2015-05-19 21:00:54 +02:00
Mateusz Loskot
1e89d43640 Fully qualify uses of session class with namespace soci::session.
This should solve compilation errors on OSX where struct session defined in
global namespace in /usr/include/sys/proc.h conflicts with unqualified uses of
soci::session.
Fixes #340
2015-05-19 14:12:12 +02:00
Mateusz Loskot
3494b2ba6b Wrap stream operator for boost::optional<int> with HAVE_BOOST 2015-05-19 10:23:43 +02:00
Benjamin Blundell
48a8bfab0e Added the C++11 changes back in 2015-05-18 13:59:08 +01:00
Vadim Zeitlin
bc4abd7172 Throw instead of truncating VARCHAR columns in Firebird backend.
Silently truncating the data to fit into a column is a bad idea, just don't do
this.

Also add a unit test verifying that an exception is indeed thrown if the value
being inserted doesn't fit in the column, except for SQLite where anything
fits and MySQL where it doesn't but just gets silently truncated by the
database by default.

Finally add a helper on_after_ddl() method to the test context class to allow
creating tables in the common test code instead of having to always do it in
RDBMS-specific way, even when the DDL uses completely standard SQL and the
only difference is that Firebird needs a commit after executing it.

Closes #51.
2015-04-21 15:55:51 +02:00
Vadim Zeitlin
76b3089bcc Add soci_error::get_error_message() method.
This will only become useful after the upcoming commits which will extend
what() to return more information about the exception, but commit this
separately as there are only trivial changes in this commit: just use
std::string returned by get_error_message() instead of char* returned by
what() in the tests.
2015-04-01 14:52:58 +02:00
Vadim Zeitlin
c9dbe19041 Move all tests from tests/assert to tests directory itself.
"assert" in the name of the directory doesn't make any sense any more as we
don't use asserts in the test code now that we use CATCH.

Also extend the tests description in the README.md.
2015-04-01 14:41:35 +02:00