summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamroot.jam15
-rw-r--r--libdbpp/column.cpp5
-rw-r--r--libdbpp/column.h11
-rw-r--r--libdbpp/command.cpp6
-rw-r--r--libdbpp/command.h17
-rw-r--r--libdbpp/connection.cpp10
-rw-r--r--libdbpp/mockDatabase.cpp8
-rw-r--r--libdbpp/selectcommand.cpp4
-rw-r--r--libdbpp/sqlParse.ll10
-rw-r--r--libdbpp/tablepatch.cpp1
-rw-r--r--libdbpp/unittests/Jamfile.jam2
m---------libdbpp/unittests/libdbpp-mysql0
m---------libdbpp/unittests/libdbpp-odbc0
m---------libdbpp/unittests/libdbpp-postgresql0
m---------libdbpp/unittests/libdbpp-sqlite0
-rw-r--r--libdbpp/unittests/mockdb.cpp4
-rw-r--r--libdbpp/unittests/testParse.cpp2
-rw-r--r--libdbpp/unittests/testPatch.cpp24
-rw-r--r--libdbpp/unittests/testUtils.cpp27
19 files changed, 86 insertions, 60 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index b13bf61..51d89b0 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -1,4 +1,5 @@
import os ;
+import testing ;
using gcc : : [ os.environ CXX ] ;
using pkg-config ;
@@ -15,6 +16,20 @@ project
<variant>debug:<warnings>extra
<variant>debug:<warnings-as-errors>on
<variant>debug:<cflags>-Wnon-virtual-dtor
+ <variant>debug:<cflags>-Wold-style-cast
+ <variant>debug:<cflags>-Wcast-align
+ <variant>debug:<cflags>-Wunused
+ <variant>debug:<cflags>-Woverloaded-virtual
+ <variant>debug:<cflags>-Wpedantic
+ <variant>debug:<cflags>-Wconversion
+ <variant>debug:<cflags>-Wsign-conversion
+ <variant>debug:<cflags>-Wnull-dereference
+ <variant>debug:<cflags>-Wdouble-promotion
+ <variant>debug:<cflags>-Wformat=2
+ <toolset>gcc,<variant>debug:<cflags>-Wduplicated-cond
+ <toolset>gcc,<variant>debug:<cflags>-Wduplicated-branches
+ <toolset>gcc,<variant>debug:<cflags>-Wlogical-op
+ <toolset>gcc,<variant>debug:<cflags>-Wuseless-cast
<variant>coverage:<coverage>on
<toolset>tidy:<checkxx>boost-*
<toolset>tidy:<checkxx>bugprone-*
diff --git a/libdbpp/column.cpp b/libdbpp/column.cpp
index 0f862de..8b13462 100644
--- a/libdbpp/column.cpp
+++ b/libdbpp/column.cpp
@@ -7,14 +7,12 @@
namespace DB {
Column::Column(const Glib::ustring & n, unsigned int i) : colNo(i), name(n.collate_key()) { }
- Column::~Column() = default;
-
static std::string
demangle(const char * const mangled)
{
std::unique_ptr<char, decltype(&free)> r(abi::__cxa_demangle(mangled, nullptr, nullptr, nullptr), &free);
return &*r;
- };
+ }
InvalidConversion::InvalidConversion(const char * const f, const char * const t) :
from(demangle(f)), to(demangle(t))
@@ -42,5 +40,4 @@ namespace DB {
{
throw DB::ColumnTypeNotSupported();
}
-
}
diff --git a/libdbpp/column.h b/libdbpp/column.h
index e4c6895..17f6223 100644
--- a/libdbpp/column.h
+++ b/libdbpp/column.h
@@ -6,7 +6,14 @@
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <c++11Helpers.h>
#include <exception.h>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#ifndef __clang__
+# pragma GCC diagnostic ignored "-Wuseless-cast"
+#endif
#include <glibmm/ustring.h>
+#pragma GCC diagnostic pop
#include <memory>
#include <optional>
#include <visibility.h>
@@ -41,7 +48,7 @@ namespace DB {
public:
/// Creates a new column with the given name and ordinal.
Column(const Glib::ustring &, unsigned int);
- virtual ~Column() = 0;
+ virtual ~Column() = default;
/// Standard special members
SPECIAL_MEMBERS_MOVE_RO(Column);
@@ -123,7 +130,7 @@ namespace DB {
return;
}
if constexpr (std::is_convertible<T, D>::value) {
- target = (T)v;
+ target = static_cast<T>(v);
return;
}
}
diff --git a/libdbpp/command.cpp b/libdbpp/command.cpp
index b4eec6b..f2c6934 100644
--- a/libdbpp/command.cpp
+++ b/libdbpp/command.cpp
@@ -2,9 +2,9 @@
#include "connection.h"
#include <factory.impl.h>
-INSTANTIATEFACTORY(DB::CommandOptions, std::size_t, const DB::CommandOptionsMap &);
-NAMEDFACTORY("", DB::CommandOptions, DB::CommandOptionsFactory);
-PLUGINRESOLVER(DB::CommandOptionsFactory, DB::Connection::resolvePlugin);
+INSTANTIATEFACTORY(DB::CommandOptions, std::size_t, const DB::CommandOptionsMap &)
+NAMEDFACTORY("", DB::CommandOptions, DB::CommandOptionsFactory)
+PLUGINRESOLVER(DB::CommandOptionsFactory, DB::Connection::resolvePlugin)
DB::Command::Command(std::string s) : sql(std::move(s)) { }
diff --git a/libdbpp/command.h b/libdbpp/command.h
index 1468e2b..e368b5c 100644
--- a/libdbpp/command.h
+++ b/libdbpp/command.h
@@ -8,7 +8,14 @@
#include <boost/lexical_cast.hpp>
#include <c++11Helpers.h>
#include <factory.h>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#ifndef __clang__
+# pragma GCC diagnostic ignored "-Wuseless-cast"
+#endif
#include <glibmm/ustring.h>
+#pragma GCC diagnostic pop
#include <memory>
#include <type_traits>
#include <visibility.h>
@@ -173,12 +180,12 @@ namespace DB {
bindNull(i); \
}
/// @cond
- OPTWRAPPER(bindParamI);
- OPTWRAPPER(bindParamF);
+ OPTWRAPPER(bindParamI)
+ OPTWRAPPER(bindParamF)
// NOLINTNEXTLINE(hicpp-no-array-decay)
- OPTWRAPPER(bindParamS);
- OPTWRAPPER(bindParamB);
- OPTWRAPPER(bindParamT);
+ OPTWRAPPER(bindParamS)
+ OPTWRAPPER(bindParamB)
+ OPTWRAPPER(bindParamT)
/// @endcond
#undef OPTWRAPPER
/// Bind a (possibly null) c-string to parameter i.
diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp
index e281aaf..4ba779d 100644
--- a/libdbpp/connection.cpp
+++ b/libdbpp/connection.cpp
@@ -132,7 +132,7 @@ DB::Connection::bulkUploadData(std::istream & in) const
}
std::array<char, BUFSIZ> buf {};
size_t total = 0;
- for (std::streamsize r; (r = in.readsome(buf.data(), buf.size())) > 0;) {
+ for (std::size_t r; (r = static_cast<std::size_t>(in.readsome(buf.data(), buf.size()))) > 0;) {
bulkUploadData(buf.data(), r);
total += r;
}
@@ -151,8 +151,8 @@ DB::Connection::bulkUploadData(FILE * in) const
bulkUploadData(buf.data(), r);
total += r;
}
- if ((int)r < 0) {
- throw std::system_error(-r, std::system_category());
+ if (-r > 0) {
+ throw std::system_error(static_cast<int>(-r), std::system_category());
}
return total;
}
@@ -198,5 +198,5 @@ DB::TransactionScope::~TransactionScope() noexcept
}
}
-INSTANTIATEFACTORY(DB::Connection, std::string);
-PLUGINRESOLVER(DB::ConnectionFactory, DB::Connection::resolvePlugin);
+INSTANTIATEFACTORY(DB::Connection, std::string)
+PLUGINRESOLVER(DB::ConnectionFactory, DB::Connection::resolvePlugin)
diff --git a/libdbpp/mockDatabase.cpp b/libdbpp/mockDatabase.cpp
index d52413e..8c168cf 100644
--- a/libdbpp/mockDatabase.cpp
+++ b/libdbpp/mockDatabase.cpp
@@ -7,10 +7,10 @@
#include <modifycommand.h>
#include <plugins.impl.h>
-INSTANTIATEPLUGINOF(DB::MockDatabase);
+INSTANTIATEPLUGINOF(DB::MockDatabase)
INSTANTIATEFACTORY(
- DB::MockDatabase, const std::string &, const std::string &, const std::vector<std::filesystem::path> &);
-PLUGINRESOLVER(DB::MockDatabaseFactory, DB::Connection::resolvePlugin);
+ DB::MockDatabase, const std::string &, const std::string &, const std::vector<std::filesystem::path> &)
+PLUGINRESOLVER(DB::MockDatabaseFactory, DB::Connection::resolvePlugin)
namespace DB {
@@ -25,7 +25,7 @@ namespace DB {
void
MockDatabase::PlaySchemaScripts(const std::vector<std::filesystem::path> & ss) const
{
- auto conn = ConnectionPtr(openConnection());
+ auto conn = openConnection();
try {
for (const auto & s : ss) {
conn->beginTx();
diff --git a/libdbpp/selectcommand.cpp b/libdbpp/selectcommand.cpp
index 216c8f8..171c1b7 100644
--- a/libdbpp/selectcommand.cpp
+++ b/libdbpp/selectcommand.cpp
@@ -33,7 +33,7 @@ namespace DB {
boost::multi_index::member<DB::Column, const std::string, &DB::Column::name>>>>;
class SelectCommand::Columns : public ColumnsBase {
};
-};
+}
DB::SelectCommand::SelectCommand(const std::string & sql) : DB::Command(sql), columns(std::make_unique<Columns>()) { }
@@ -66,7 +66,7 @@ DB::SelectCommand::getOrdinal(const Glib::ustring & n) const
unsigned int
DB::SelectCommand::columnCount() const
{
- return columns->size();
+ return static_cast<unsigned int>(columns->size());
}
const DB::ColumnPtr &
diff --git a/libdbpp/sqlParse.ll b/libdbpp/sqlParse.ll
index d36dae5..37dfba1 100644
--- a/libdbpp/sqlParse.ll
+++ b/libdbpp/sqlParse.ll
@@ -10,9 +10,13 @@
%{
#include "sqlParse.h"
#pragma GCC diagnostic ignored "-Wsign-compare"
+#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#ifdef __clang__
#pragma GCC diagnostic ignored "-Wnull-conversion"
+#else
+#pragma GCC diagnostic ignored "-Wuseless-cast"
#endif
%}
@@ -68,7 +72,7 @@ scriptdir "$SCRIPTDIR"
}
<MCOMMENT><<EOF>> {
- throw SqlParseException("Unterminated comment", yylineno);
+ throw SqlParseException("Unterminated comment", static_cast<unsigned int>(yylineno));
}
<LCOMMENT>{non_newline}* {
@@ -128,7 +132,7 @@ scriptdir "$SCRIPTDIR"
}
<DOLLARQUOTE><<EOF>> {
- throw SqlParseException("Unterminated dollar quoted string", yylineno);
+ throw SqlParseException("Unterminated dollar quoted string", static_cast<unsigned int>(yylineno));
}
<QUOTE>{any} {
@@ -136,7 +140,7 @@ scriptdir "$SCRIPTDIR"
}
<QUOTE><<EOF>> {
- throw SqlParseException("Unterminated quoted string", yylineno);
+ throw SqlParseException("Unterminated quoted string", static_cast<unsigned int>(yylineno));
}
<STATEMENT>{term} {
diff --git a/libdbpp/tablepatch.cpp b/libdbpp/tablepatch.cpp
index 28f8350..bbad348 100644
--- a/libdbpp/tablepatch.cpp
+++ b/libdbpp/tablepatch.cpp
@@ -286,7 +286,6 @@ DB::Connection::patchUpdates(TablePatch * tp)
// -----------------------------------------------------------------
auto upd = modify(updSql);
unsigned int offset = 0;
- tp->where->bindParams(upd.get(), offset);
if (tp->where) {
tp->where->bindParams(upd.get(), offset);
}
diff --git a/libdbpp/unittests/Jamfile.jam b/libdbpp/unittests/Jamfile.jam
index 915cdf2..61c1e5e 100644
--- a/libdbpp/unittests/Jamfile.jam
+++ b/libdbpp/unittests/Jamfile.jam
@@ -1,5 +1,3 @@
-import testing ;
-
import feature : feature ;
path-constant me : . ;
diff --git a/libdbpp/unittests/libdbpp-mysql b/libdbpp/unittests/libdbpp-mysql
-Subproject 0778234c3ffd82f3b9987bcb64de32f2647aba4
+Subproject 7b56849be41fdd342c8d92c243df6370a53c830
diff --git a/libdbpp/unittests/libdbpp-odbc b/libdbpp/unittests/libdbpp-odbc
-Subproject d046504464cb476be9ff3f810ad93f6c3961c8a
+Subproject dbf98a34e08558b91328cb414447e9961c22203
diff --git a/libdbpp/unittests/libdbpp-postgresql b/libdbpp/unittests/libdbpp-postgresql
-Subproject 30133bd4281d777a6b32fa203fca5c624943507
+Subproject 216c87cbb7228d9130eead5e374dfd7a11a96b9
diff --git a/libdbpp/unittests/libdbpp-sqlite b/libdbpp/unittests/libdbpp-sqlite
-Subproject c58e1ee62175d8babc69bb0ff54b4625725d594
+Subproject 7e5c360a8c8eee8ebe8b1c18e49be5b4af8dac5
diff --git a/libdbpp/unittests/mockdb.cpp b/libdbpp/unittests/mockdb.cpp
index 722592a..30180b9 100644
--- a/libdbpp/unittests/mockdb.cpp
+++ b/libdbpp/unittests/mockdb.cpp
@@ -78,7 +78,7 @@ MockMock::DropDatabase() const
{
}
-FACTORY(MockMock, DB::MockDatabaseFactory);
-FACTORY(MockDb, DB::ConnectionFactory);
+FACTORY(MockMock, DB::MockDatabaseFactory)
+FACTORY(MockDb, DB::ConnectionFactory)
// LCOV_EXCL_STOP
diff --git a/libdbpp/unittests/testParse.cpp b/libdbpp/unittests/testParse.cpp
index 6991242..29ffc38 100644
--- a/libdbpp/unittests/testParse.cpp
+++ b/libdbpp/unittests/testParse.cpp
@@ -10,7 +10,7 @@
#include <vector>
using SQLs = std::vector<std::string>;
-BOOST_TEST_SPECIALIZED_COLLECTION_COMPARE(SQLs);
+BOOST_TEST_SPECIALIZED_COLLECTION_COMPARE(SQLs)
class RecordingParser : std::fstream, public DB::SqlParse {
public:
diff --git a/libdbpp/unittests/testPatch.cpp b/libdbpp/unittests/testPatch.cpp
index e81f9d7..cc9fd24 100644
--- a/libdbpp/unittests/testPatch.cpp
+++ b/libdbpp/unittests/testPatch.cpp
@@ -48,11 +48,11 @@ public:
}
};
-BOOST_FIXTURE_TEST_SUITE(mock, Mock);
+BOOST_FIXTURE_TEST_SUITE(mock, Mock)
BOOST_AUTO_TEST_CASE(sanityFail)
{
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
tp.src = "source";
@@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(sanityFail)
BOOST_AUTO_TEST_CASE(noTx)
{
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
tp.src = "source";
@@ -73,12 +73,12 @@ BOOST_AUTO_TEST_CASE(noTx)
BOOST_REQUIRE_THROW(db->patchTable(&tp), DB::TransactionRequired);
}
-BOOST_AUTO_TEST_SUITE_END();
+BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(testBasic)
{
Mock mock;
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
tp.src = "source";
@@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(testBasic)
BOOST_AUTO_TEST_CASE(allKeys)
{
Mock mock;
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
tp.src = "source";
@@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(allKeys)
BOOST_AUTO_TEST_CASE(testOrder)
{
Mock mock;
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
OrderByA order;
@@ -156,7 +156,7 @@ BOOST_AUTO_TEST_CASE(testOrder)
BOOST_AUTO_TEST_CASE(testWhere)
{
Mock mock;
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
WhereAequals1 where;
@@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE(testWhere)
BOOST_AUTO_TEST_CASE(testInstead)
{
Mock mock;
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
MarkDeleted mark;
@@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE(testSrcExprTable)
{
Mock mock;
DB::StaticSqlWriter s("source");
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
tp.srcExpr = &s;
@@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(testSrcExprSelectTable)
{
Mock mock;
DB::StaticSqlWriter s("(SELECT * FROM source)");
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
tp.srcExpr = &s;
@@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE(testSrcExprSelectFilteredTable)
{
Mock mock;
BindInt s("(SELECT s.* FROM source s WHERE s.a = ?)", 1);
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
BOOST_REQUIRE(db);
DB::TablePatch tp;
tp.srcExpr = &s;
diff --git a/libdbpp/unittests/testUtils.cpp b/libdbpp/unittests/testUtils.cpp
index cc5cdc3..8fb0510 100644
--- a/libdbpp/unittests/testUtils.cpp
+++ b/libdbpp/unittests/testUtils.cpp
@@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE(stdforOverRowsStructuredBindingOptional)
BOOST_AUTO_TEST_CASE(execute)
{
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
db->execute("UPDATE forEachRow SET a = 2");
}
@@ -123,7 +123,6 @@ BOOST_AUTO_TEST_CASE(columns)
auto sel = db->select("SELECT a, b, c, d, e FROM forEachRow ORDER BY a LIMIT 1");
sel->execute();
BOOST_REQUIRE_THROW((void)(*sel)[5], DB::ColumnIndexOutOfRange);
- BOOST_REQUIRE_THROW((void)(*sel)[-1], DB::ColumnIndexOutOfRange);
BOOST_REQUIRE_EQUAL(0, (*sel)[0].colNo);
BOOST_REQUIRE_EQUAL(4, (*sel)[4].colNo);
BOOST_REQUIRE_EQUAL("c", (*sel)[2].name);
@@ -167,7 +166,7 @@ BOOST_AUTO_TEST_CASE(extract)
BOOST_AUTO_TEST_CASE(bulkLoadStream)
{
std::ifstream in(rootDir / "source.dat");
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
db->beginBulkUpload("bulk1", "");
BOOST_REQUIRE_EQUAL(56, db->bulkUploadData(in));
db->endBulkUpload(nullptr);
@@ -179,7 +178,7 @@ BOOST_AUTO_TEST_CASE(bulkLoadStream)
BOOST_AUTO_TEST_CASE(bulkLoadFile)
{
auto f = fopen((rootDir / "source.dat").c_str(), "r");
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
db->beginBulkUpload("bulk2", "");
BOOST_REQUIRE_EQUAL(56, db->bulkUploadData(f));
db->endBulkUpload(nullptr);
@@ -217,7 +216,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(nullBind, Str, StringTypes)
BOOST_AUTO_TEST_CASE(iceNullBind)
{
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
auto ins = db->modify("INSERT INTO forEachRow VALUES(?, ?, ?, ?, ?, ?)");
ins->bindParamI(0, IceUtil::Optional<int>());
ins->bindParamF(1, IceUtil::Optional<double>());
@@ -238,7 +237,7 @@ BOOST_AUTO_TEST_CASE(iceNullBind)
BOOST_AUTO_TEST_CASE(charStarBindNull)
{
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
db->modify("DELETE FROM forEachRow")->execute();
auto ins = db->modify("INSERT INTO forEachRow(a, c) VALUES(?, ?)");
char * cs = nullptr;
@@ -265,16 +264,16 @@ BOOST_AUTO_TEST_CASE(charStarBindNull)
BOOST_AUTO_TEST_CASE(bind)
{
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
auto m = db->modify("doesn't matter, only testing compile");
- m->bindParamI(0, (unsigned char)1);
- m->bindParamI(0, (char)1);
- m->bindParamI(0, (time_t)1);
+ m->bindParamI(0, static_cast<unsigned char>(1));
+ m->bindParamI(0, static_cast<char>(1));
+ m->bindParamI(0, static_cast<time_t>(1));
}
BOOST_AUTO_TEST_CASE(bindIntPtr)
{
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
db->modify("DELETE FROM forEachRow")->execute();
auto ins = db->modify("INSERT INTO forEachRow(a, b) VALUES(?, ?)");
int * is = nullptr;
@@ -306,7 +305,7 @@ BOOST_AUTO_TEST_CASE(bindIntPtr)
BOOST_FIXTURE_TEST_CASE(traits_bind, DB::TestCore)
{
using namespace std::literals;
- auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ auto db = DB::MockDatabase::openConnectionTo("pqmock");
auto cmd = db->select("select x is null, format('%s', x) from (select ? x) d");
auto cmd2 = db->select("select x is null, x from (select ?::bytea x) d");
auto check = [](int line, const auto & v, bool isNull, const auto & testval, auto & cmd) {
@@ -323,12 +322,12 @@ BOOST_FIXTURE_TEST_CASE(traits_bind, DB::TestCore)
check(__LINE__, testInt, false, "43"sv, cmd);
check(__LINE__, std::make_unique<short>(testInt), false, "43"sv, cmd);
check(__LINE__, std::unique_ptr<short>(), true, ""sv, cmd);
- check(__LINE__, (unsigned int)testInt, false, "43"sv, cmd);
+ check(__LINE__, static_cast<unsigned int>(testInt), false, "43"sv, cmd);
check(__LINE__, &testInt, false, "43"sv, cmd);
check(__LINE__, testDouble, false, "3.14"sv, cmd);
check(__LINE__, std::make_shared<float>(testDouble), false, "3.14"sv, cmd);
check(__LINE__, std::shared_ptr<float>(), true, ""sv, cmd);
- check(__LINE__, (float)testDouble, false, "3.14"sv, cmd);
+ check(__LINE__, static_cast<float>(testDouble), false, "3.14"sv, cmd);
check(__LINE__, &testDouble, false, "3.14"sv, cmd);
check(__LINE__, testString, false, testString, cmd);
check(__LINE__, &testString, false, testString, cmd);