Commit b510e1a6 authored by Sergei Nikulov's avatar Sergei Nikulov Committed by GitHub

moved to latest Catch UT Framework (#544)

* Moved to latest Catch UT Framework
* Added -Wextra to gcc and clang
* Fixed discovered issues
parent 33ae81a7
......@@ -49,7 +49,7 @@ if (MSVC)
else()
set(SOCI_GCC_CLANG_COMMON_FLAGS
"-pedantic -Werror -Wno-error=parentheses -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wfloat-equal -Wredundant-decls -Wno-long-long")
"-pedantic -Werror -Wno-error=parentheses -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wfloat-equal -Wredundant-decls -Wno-long-long")
if (SOCI_CXX_C11)
......
......@@ -35,7 +35,7 @@ public:
// the newTarget connection string is a hint that can be ignored
// by external means.
virtual void failed(bool & /* out */ /* retry */,
std::string & /* out */ newTarget) {}
std::string & /* out */ /* newTarget */) {}
// Called when there was a failure that prevents further failover attempts.
virtual void aborted() {}
......
......@@ -226,8 +226,8 @@ public:
virtual std::size_t read(std::size_t offset, char* buf,
std::size_t toRead) = 0;
virtual std::size_t read_from_start(char * buf, std::size_t toRead,
std::size_t offset)
virtual std::size_t read_from_start(char * /* buf */, std::size_t /* toRead */,
std::size_t /* offset */)
{
throw soci_error("read_from_start is not implemented for this backend");
}
......@@ -235,8 +235,8 @@ public:
virtual std::size_t write(std::size_t offset, char const* buf,
std::size_t toWrite) = 0;
virtual std::size_t write_from_start(const char * buf, std::size_t toWrite,
std::size_t offset)
virtual std::size_t write_from_start(const char * /* buf */, std::size_t /* toWrite */,
std::size_t /* offset */)
{
throw soci_error("write_from_start is not implemented for this backend");
}
......
......@@ -93,7 +93,7 @@ void firebird_vector_into_type_backend::exchangeData(std::size_t row)
break;
case x_stdtm:
{
std::tm data;
std::tm data = std::tm();
tmDecode(var->sqltype, buf_, &data);
setIntoVector(data_, row, data);
}
......
......@@ -145,7 +145,7 @@ void mysql_vector_into_type_backend::post_fetch(bool gotData, indicator *ind)
case x_stdtm:
{
// attempt to parse the string and convert to std::tm
std::tm t = {};
std::tm t = std::tm();
parse_std_tm(buf, t);
set_invector_(data_, i, t);
......
......@@ -154,7 +154,7 @@ void postgresql_vector_into_type_backend::post_fetch(bool gotData, indicator * i
case x_stdtm:
{
// attempt to parse the string and convert to std::tm
std::tm t = {};
std::tm t = std::tm();
parse_std_tm(buf, t);
set_invector_(data_, i, t);
......
......@@ -223,7 +223,7 @@ void sqlite3_vector_into_type_backend::post_fetch(bool gotData, indicator * ind)
case dt_blob:
{
// attempt to parse the string and convert to std::tm
std::tm t;
std::tm t = std::tm();
parse_std_tm(col.buffer_.constData_, t);
set_in_vector(data_, i, t);
......
......@@ -1498,7 +1498,7 @@ SOCI_DECL void soci_set_use_date(statement_handle st, char const * name, char co
return;
}
std::tm dt = {};
std::tm dt = std::tm();
bool const converted = string_to_date(val, dt, *wrapper);
if (converted == false)
{
......@@ -1701,7 +1701,7 @@ SOCI_DECL void soci_set_use_date_v(statement_handle st,
return;
}
std::tm dt = {};
std::tm dt = std::tm();
bool const converted = string_to_date(val, dt, *wrapper);
if (converted == false)
{
......
This diff is collapsed.
......@@ -594,7 +594,7 @@ TEST_CASE_METHOD(common_tests, "Use and into", "[core][into]")
SECTION("Round trip works for date without time")
{
std::tm nov15;
std::tm nov15 = std::tm();
nov15.tm_year = 105;
nov15.tm_mon = 10;
nov15.tm_mday = 15;
......@@ -604,7 +604,7 @@ TEST_CASE_METHOD(common_tests, "Use and into", "[core][into]")
sql << "insert into soci_test(tm) values(:tm)", use(nov15);
std::tm t;
std::tm t = std::tm();
sql << "select tm from soci_test", into(t);
CHECK(t.tm_year == 105);
CHECK(t.tm_mon == 10);
......@@ -616,7 +616,7 @@ TEST_CASE_METHOD(common_tests, "Use and into", "[core][into]")
SECTION("Round trip works for date with time")
{
std::tm nov15;
std::tm nov15 = std::tm();
nov15.tm_year = 105;
nov15.tm_mon = 10;
nov15.tm_mday = 15;
......@@ -626,7 +626,7 @@ TEST_CASE_METHOD(common_tests, "Use and into", "[core][into]")
sql << "insert into soci_test(tm) values(:tm)", use(nov15);
std::tm t;
std::tm t = std::tm();
sql << "select tm from soci_test", into(t);
CHECK(t.tm_year == 105);
CHECK(t.tm_mon == 10);
......@@ -658,7 +658,7 @@ TEST_CASE_METHOD(common_tests, "Use and into", "[core][into]")
CHECK(ind == i_null);
// additional test for NULL with std::tm
std::tm t;
std::tm t = std::tm();
sql << "select tm from soci_test", into(t, ind);
CHECK(ind == i_null);
......@@ -1051,7 +1051,7 @@ TEST_CASE_METHOD(common_tests, "Repeated and bulk fetch", "[core][bulk]")
CHECK(count == rowsToTest);
{
std::tm t;
std::tm t = std::tm();
int i = 0;
statement st = (sql.prepare <<
......@@ -1326,7 +1326,7 @@ TEST_CASE_METHOD(common_tests, "Use type conversion", "[core][use]")
SECTION("std::tm")
{
std::tm t;
std::tm t = std::tm();
t.tm_year = 105;
t.tm_mon = 10;
t.tm_mday = 19;
......@@ -1335,7 +1335,7 @@ TEST_CASE_METHOD(common_tests, "Use type conversion", "[core][use]")
t.tm_sec = 57;
sql << "insert into soci_test(tm) values(:t)", use(t);
std::tm t2;
std::tm t2 = std::tm();
t2.tm_year = 0;
t2.tm_mon = 0;
t2.tm_mday = 0;
......@@ -1445,7 +1445,7 @@ TEST_CASE_METHOD(common_tests, "Use type conversion", "[core][use]")
SECTION("const std::tm")
{
std::tm t;
std::tm t = std::tm();
t.tm_year = 105;
t.tm_mon = 10;
t.tm_mday = 19;
......@@ -1455,7 +1455,7 @@ TEST_CASE_METHOD(common_tests, "Use type conversion", "[core][use]")
std::tm const & ct = t;
sql << "insert into soci_test(tm) values(:t)", use(ct);
std::tm t2;
std::tm t2 = std::tm();
t2.tm_year = 0;
t2.tm_mon = 0;
t2.tm_mday = 0;
......@@ -1697,7 +1697,7 @@ TEST_CASE_METHOD(common_tests, "Use vector", "[core][use][vector]")
SECTION("std::tm")
{
std::vector<std::tm> v;
std::tm t;
std::tm t = std::tm();
t.tm_year = 105;
t.tm_mon = 10;
t.tm_mday = 26;
......@@ -2070,7 +2070,7 @@ TEST_CASE_METHOD(common_tests, "Dynamic row binding", "[core][dynamic]")
double d;
int i;
std::string s;
std::tm t;
std::tm t = std::tm();
std::string c;
r >> d >> i >> s >> t >> c;
......@@ -2811,14 +2811,27 @@ TEST_CASE_METHOD(common_tests, "Rowset expected exception", "[core][exception][r
auto_table_creator tableCreator(tc_.table_creator_1(sql));
sql << "insert into soci_test(str) values('abc')";
std::string troublemaker;
CHECK_THROWS_AS(
std::string troublemaker;
rowset<std::string> rs1 = (sql.prepare << "select str from soci_test",
into(troublemaker)),
soci_error
rowset<std::string>((sql.prepare << "select str from soci_test", into(troublemaker))),
soci_error
);
}
// functor for next test
struct THelper
{
THelper()
: val_()
{
}
void operator()(int i)
{
val_ = i;
}
int val_;
};
// test for handling NULL values with expected exception:
// "Null value fetched and no indicator defined."
TEST_CASE_METHOD(common_tests, "NULL expected exception", "[core][exception][null]")
......@@ -2833,17 +2846,8 @@ TEST_CASE_METHOD(common_tests, "NULL expected exception", "[core][exception][nul
sql << "insert into soci_test(val) values(3)";
rowset<int> rs = (sql.prepare << "select val from soci_test order by val asc");
int tester = 0;
CHECK_THROWS_AS(
for (rowset<int>::const_iterator it = rs.begin(); it != rs.end(); ++it)
{
tester = *it;
},
soci_error
);
(void)tester;
CHECK_THROWS_AS( std::for_each(rs.begin(), rs.end(), THelper()), soci_error );
}
// This is like the first dynamic binding test but with rowset and iterators use
......@@ -3599,7 +3603,7 @@ TEST_CASE_METHOD(common_tests, "Boost date", "[core][boost][datetime]")
{
auto_table_creator tableCreator(tc_.table_creator_1(sql));
std::tm nov15;
std::tm nov15 = std::tm();
nov15.tm_year = 105;
nov15.tm_mon = 10;
nov15.tm_mday = 15;
......@@ -3636,7 +3640,7 @@ TEST_CASE_METHOD(common_tests, "Boost date", "[core][boost][datetime]")
sql << "insert into soci_test(tm) values(:tm)", use(bgd);
std::tm t;
std::tm t = std::tm();
sql << "select tm from soci_test", into(t);
CHECK(t.tm_year == 108);
......
......@@ -170,7 +170,9 @@ TEST_CASE("Firebird date and time", "[firebird][datetime]")
sql.begin();
std::tm t1, t2, t3;
std::tm t1 = std::tm();
std::tm t2 = std::tm();
std::tm t3 = std::tm();
std::time_t now = std::time(NULL);
std::tm t = *std::localtime(&now);
sql << "insert into test3(p1, p2, p3) "
......@@ -1098,7 +1100,7 @@ TEST_CASE("Firebird string coercions", "[firebird][string]")
{
double a;
std::tm b, c, d;
std::tm b = std::tm(), c = std::tm(), d = std::tm();
sql << "select a, b, c, d from test12",
into(a), into(b), into(c), into(d);
CHECK(std::fabs(a - (-3.141)) < 0.000001);
......
......@@ -361,7 +361,7 @@ TEST_CASE("MySQL number conversion", "[mysql][float][int]")
TEST_CASE("MySQL datetime", "[mysql][datetime]")
{
soci::session sql(backEnd, connectString);
std::tm t;
std::tm t = std::tm();
sql << "select maketime(19, 54, 52)", into(t);
CHECK(t.tm_year == 100);
CHECK(t.tm_mon == 0);
......
......@@ -476,7 +476,7 @@ TEST_CASE("PostgreSQL datetime", "[postgresql][datetime]")
soci::session sql(backEnd, connectString);
std::string someDate = "2009-06-17 22:51:03.123";
std::tm t1, t2, t3;
std::tm t1 = std::tm(), t2 = std::tm(), t3 = std::tm();
sql << "select :sd::date, :sd::time, :sd::timestamp",
use(someDate, "sd"), into(t1), into(t2), into(t3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment