Commit Graph

42 Commits

Author SHA1 Message Date
Heiko Rabe 51d058f04c Repair VC8 compile of test applications (#593)
Fix compilation issues for Visual C++ 8.0 (VS2005)

* Add _WIN32_WINNT minimal required version to soci-platform.h to fix windows.h issue related to use of Add/RemoveVectoredExceptionHandler.
* Override SECTION macro since default macro parameter (3 required / 2 given or 2 required / 1 given) do not expand and lead to syntax error.
2017-09-23 12:57:38 +02:00
Vadim Zeitlin b85ec90c65 Check that inserting malformed XML values fails
Skip this test for Firebird which doesn't have real XML support.
2017-09-15 17:31:04 +02:00
Vadim Zeitlin fabb8f0f03 Make XML comparison in the test work for SQL Server too
Adding a new line to work around the problem with Oracle didn't allow
this test to pass with SQL Server which strips the newline if it is
present.

So don't modify the input, but do strip the trailing newline from output
if it's present in it to accommodate Oracle, but to allow SQL Server to
work too.
2017-09-15 01:44:34 +02:00
Vadim Zeitlin bd236c8c8e Merge branch 'xml-firebird'
Closes #578.
2017-09-15 00:32:12 +02:00
Vadim Zeitlin 3a76774255 Merge branch 'odbc-vec-into-null'
Closes #583.
2017-09-14 17:32:18 +02:00
Vadim Zeitlin df40399234 Fix bug with null strings in bull selections in ODBC and DB2
The changes of be4f26feac (ODBC) and
51c4c1e1a3 (DB2) didn't handle null
strings correctly, the indicator value for them is -1 and can't be used
as length.

Fix this now by adding a test for this particular case.

Closes #581.
2017-09-14 16:30:09 +02:00
Vadim Zeitlin 6ca9cd64a4 Add REQUIRE_NOTHROW() around SQL statements in the string test
This will result in better error messages from CATCH if any of these
statements throws an exception again.
2017-09-14 15:03:46 +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 85159db6f9 Refactor: move XML and CLOB tests to common code
Don't duplicate them for PostgreSQL and Oracle, especially because they
will be needed for other backends in the future too.
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
Vadim Zeitlin 521a840855 Improve get_affected_rows() documentation
Mention that the exact result of this method can't be relied upon for
the partially successful statements when using ODBC: some drivers
(including the widely used MS SQL native client) simply don't return
this information at all, while others (MySQL) just return wrong number
of rows.

Also remove the apparently obsolete note about this method not supported
in the Oracle backend as it does seem to implement it.
2017-07-22 01:00:04 +02:00
Vadim Zeitlin 1a0eeb1863 Fix harmless variable shadowing warnings
Suppress VC14 (a.k.a. MSVS 2015) C4456 warning about shadowing variables
in outer scope.

No real changes.
2017-07-22 01:00:04 +02:00
Vadim Zeitlin 06915e483c Add check for absence of unneeded truncation too
We already checked that inserting a too long string resulted in an
error, now check that inserting a string just long enough does not
result in it.
2017-07-22 01:00:00 +02:00
Vadim Zeitlin d91c2228ce Add get_dummy_from_{table,clause}() methods
These functions are helpful to allow writing queries not using any
tables portably, i.e. they basically abstract the difference between
"select ... from dual" in Oracle and just "select ..." in almost all the
other backends.
2017-07-19 02:27:13 +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
Mateusz Łoskot ec746bd1d0 Merge pull request #375 from ravselj/sqlite_load_one
Sqlite backend fetch bug
2016-08-30 23:07:50 +02:00
Vadim Zeitlin ec7d2dfc3d Define cxx_details::auto_ptr<> to get rid of preprocessor checks
Defining cxx_details::auto_ptr<> as either std::auto_ptr<> or
std::unique_ptr<> once instead of checking for SOCI_HAVE_CXX_C11 simplifies
the code and also allows to use unique_ptr<> for MSVS 2010+ which has it even
when SOCI_HAVE_CXX_C11 is not defined.

Also use cxx_details::auto_ptr<> instead of std::auto_ptr<> in the tests to
fix the build in C++11 mode with clang 3.8 due to -Wdeprecated-declarations
warnings given by it for std::auto_ptr<> (and -Werror used by CMake and which
apparently can't be overridden from command line...).
2016-02-05 15:37:43 +01:00
ArnaudD-FR 6908e473ff Specify definitions in soci-config.h
* replace all commmand line definition as -DHAS_BOOST, -DHAS_SQLITE3 by
   soci-config.h
2015-11-05 15:04:11 +01:00
MonsieurNicolas 8cd3cf5844 added test that reuses prepared statement 2015-10-21 12:42:24 -07:00
Sergei Nikulov 0cc5c50ab9 - Fixed Coverity issues for SQLite3: 12644, 12645, 12646
- Fixed gcc/clang warns produced with -Wextra switch for SQLite3
2015-10-16 12:31:23 +03:00
Miha Ravselj e07f634a71 Added additional basic functionality test from prepare, execute, fetch scenario. 2015-10-09 08:24:37 +02:00
Daniel Walter 90097ec736 added test to demonstrate bug #221 and make it valid with all backends 2015-10-08 07:17:46 +02:00
Mateusz Loskot 0530f6fec1 Avoid use of POSIX strptime function 2015-09-27 21:04:01 +02:00
Mateusz Loskot 68a335707a Add some variations for tests for use with indicators.
Test char* insert query.
Test use binding std::tm as rvalue (return from a function).
Test use with std::tm + indicators.
2015-09-27 20:53:27 +02:00
Mateusz Loskot 0d84fef306 Add std::tm checks to the use with indicators tests 2015-09-27 20:40:21 +02:00
Sergei Nikulov 063e753740 fix for #370 2015-09-24 10:24:12 +03:00
Miha Ravselj d1ad52fcd6 Add a unit test for CHAR(N) fields padding behaviour.
Use the new CHECK_EQUAL_PADDED() macro instead of just CHECK() for the CHAR(N)
fields as they can be padded, and even padded incorrectly, by some backends.

Add a new test verifying that, up to padding, CHAR(N) fields do behave
correctly.

Closes #356.
2015-07-15 04:07:32 +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
Vadim Zeitlin caa2370d5c Removed dummy and not compilable operator<<(boost::optional).
"inline namespace" doesn't compile in C++98 mode, so the old code broke
compilation with g++ 4.7 or later or clang when not using C++11.

It also seems to be completely useless as outputting "Currently not supported"
just can't be a good idea, so it is not clear why was it added in the first
place (see PR #336).
2015-07-15 03:29:54 +02:00
Benjamin Blundell ffbfdc0ef5 Inlined the pragmas for the C++11 tests 2015-05-22 14:46:36 +01: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 Łoskot 2bf3aa7ed3 Disable test of set_query_transformation with C++ lambda
Originally, it was an example sent to user.
No need to actually run the test, especially if purposely handled compiler
detection is needed. Keep it as an example to users who browse the tests.
2015-05-08 16:51:54 +02: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 ba206ede74 Extract common part of MySQL and ODBC MySQL tests in a header.
This makes it possible to reuse various MySQL-specific workarounds for both
tests without duplicating the not always trivial code.

As a side effect, fixes ODBC MySQL test which didn't pass any more since the
addition of exact double equality checks, making it use the same has_fp_bug()
as the MySQL test skips the failing test for it too now.
2015-04-21 15:55:51 +02:00
Vadim Zeitlin 4916551d47 Reorganize more unit tests to use CATCH sections.
Make the tests slightly shorter and, more importantly, specify more
information in case of test failures.

This extends the changes of 60a33f4a77.
2015-04-20 16:09:47 +02:00
Vadim Zeitlin ee0b9e4eef Fix a clash between CATCH test cases defined in different files.
Put the common test cases in their own namespace to avoid a clash between the
tests defined in soci::tests (which is brought into scope via using
directive by all the backend-specific files) and the tests defined in the
backend test sources if they happen to start at the same line.

This is just a workaround and a proper solution would, of course, be to move
the tests out of the header at all but this will have to wait.
2015-04-15 10:52:19 +02:00
Vadim Zeitlin 60a33f4a77 Reorganize "Use and into" unit test to use CATCH sections.
This makes the test slightly shorter (the line creating the table doesn't need
to be repeated many times) and, more importantly, allows us to specify the
descriptions which can be useful in case of test failures.
2015-04-15 00:54:03 +02:00
Vadim Zeitlin 8bb66107a2 Provide context of the error in soci_error when possible.
Add soci_error::add_context() and use it in statement class to record the
information about the query which resulted in the exception and, if
applicable, this query parameters.

This results in much better end user experience as the error messages now
contain information allowing to diagnose which query exactly has failed
instead of just unhelpfully saying that an error occurred.
2015-04-01 15:24:12 +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 e8e5978138 No real changes, just remove trailing whitespace.
Insignificant trailing whitespace was annoying as it resulted in extra noise
in the diffs, just get rid of it everywhere at once.
2015-04-01 14:52:39 +02:00
Vadim Zeitlin 7b8b37b470 Use REQUIRE() and not CHECK() for a test that can't be allowed to fail.
If there is no test context, the test can't continue to run and we also
shouldn't crash on the next line in this case.
2015-04-01 14:41:35 +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