summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamroot.jam2
-rw-r--r--lib/output/pq/writePqCopyStrm.h2
-rw-r--r--test/helpers.cpp1
-rw-r--r--test/test-e2e.cpp11
-rw-r--r--test/test-misc.cpp24
-rw-r--r--test/test-postgresql.cpp2
-rw-r--r--test/test-rawDataReader.cpp6
7 files changed, 30 insertions, 18 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 7b58e75..afc8e81 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -36,6 +36,8 @@ project : requirements
<toolset>gcc,<variant>debug:<cflags>-Wlogical-op
<toolset>gcc,<variant>debug:<cflags>-Wuseless-cast
<variant>coverage:<coverage>on
+ <toolset>tidy:<librarydef>boost
+ <toolset>tidy:<librarydef>std
<toolset>tidy:<checkxx>boost-*
<toolset>tidy:<checkxx>bugprone-*
<toolset>tidy:<xcheckxx>bugprone-macro-parentheses
diff --git a/lib/output/pq/writePqCopyStrm.h b/lib/output/pq/writePqCopyStrm.h
index a3ceb88..a679e6c 100644
--- a/lib/output/pq/writePqCopyStrm.h
+++ b/lib/output/pq/writePqCopyStrm.h
@@ -16,6 +16,7 @@ namespace MyGrate::Output::Pq {
void
operator()(std::integral auto v) const
{
+ // NOLINTNEXTLINE(clang-diagnostic-format-nonliteral)
fprintf(out, printer<decltype(v)>::fmt, v);
}
void
@@ -23,6 +24,7 @@ namespace MyGrate::Output::Pq {
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdouble-promotion"
+ // NOLINTNEXTLINE(clang-diagnostic-format-nonliteral)
fprintf(out, printer<decltype(v)>::fmt, v);
#pragma GCC diagnostic pop
}
diff --git a/test/helpers.cpp b/test/helpers.cpp
index 6cb6fdc..c00e786 100644
--- a/test/helpers.cpp
+++ b/test/helpers.cpp
@@ -5,6 +5,7 @@ MemStream::MemStream() : out {nullptr}, len {}, s {open_memstream(&out, &len)} {
MemStream::~MemStream()
{
fclose(s);
+ // NOLINTNEXTLINE(hicpp-no-malloc)
free(out);
}
diff --git a/test/test-e2e.cpp b/test/test-e2e.cpp
index ca65e34..3359160 100644
--- a/test/test-e2e.cpp
+++ b/test/test-e2e.cpp
@@ -65,6 +65,11 @@ public:
}
}
+ MockSetup(const MockSetup &) = delete;
+ MockSetup(MockSetup &&) = delete;
+ MockSetup & operator=(const MockSetup &) = delete;
+ MockSetup & operator=(MockSetup &&) = delete;
+
TestUpdateDatabase &
getUpdateDatabase()
{
@@ -316,9 +321,9 @@ replication_data_type_impl(Test * test)
auto rs {MyGrate::DbStmt<"SELECT val FROM testout.test ORDER BY id">::execute(&test->pqm)};
std::vector<O> outs;
outs.reserve(ROWS);
- for (auto v : *rs) {
- outs.push_back(v[0]);
- }
+ std::transform(rs->begin(), rs->end(), std::back_inserter(outs), [](const auto & v) {
+ return static_cast<O>(v[0]);
+ });
// Check values
BOOST_CHECK_EQUAL_COLLECTIONS(vals.begin(), vals.end(), outs.begin(), outs.end());
diff --git a/test/test-misc.cpp b/test/test-misc.cpp
index b4eeb41..2c4d311 100644
--- a/test/test-misc.cpp
+++ b/test/test-misc.cpp
@@ -94,7 +94,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(DbValueConvFloatToString, F, Floats)
BOOST_AUTO_TEST_CASE(create_datetime)
{
- struct tm tm;
+ struct tm tm {
+ };
time_t t {1629222289};
gmtime_r(&t, &tm);
BOOST_REQUIRE_EQUAL(tm.tm_gmtoff, 0);
@@ -106,14 +107,12 @@ BOOST_AUTO_TEST_CASE(create_datetime)
BOOST_AUTO_TEST_CASE(mod100_extract)
{
long unsigned int i {1629222289};
- BOOST_CHECK_EQUAL(MyGrate::mod100_extract(i), 89);
- BOOST_CHECK_EQUAL(MyGrate::mod100_extract(i), 22);
- BOOST_CHECK_EQUAL(MyGrate::mod100_extract(i), 22);
- BOOST_CHECK_EQUAL(MyGrate::mod100_extract(i), 29);
- BOOST_CHECK_EQUAL(MyGrate::mod100_extract(i), 16);
- BOOST_CHECK_EQUAL(MyGrate::mod100_extract(i), 0);
- BOOST_CHECK_EQUAL(MyGrate::mod100_extract(i), 0);
- BOOST_CHECK_EQUAL(MyGrate::mod100_extract(i), 0);
+ std::vector<int> extracted;
+ while (i) {
+ extracted.push_back(MyGrate::mod100_extract(i));
+ }
+ const std::initializer_list<int> expected {89, 22, 22, 29, 16};
+ BOOST_CHECK_EQUAL_COLLECTIONS(extracted.begin(), extracted.end(), expected.begin(), expected.end());
}
using ConvertTimeData = std::tuple<uint32_t, MyGrate::Time>;
@@ -137,11 +136,12 @@ BOOST_DATA_TEST_CASE(convert_time,
BOOST_AUTO_TEST_CASE(getenv_with_default)
{
+ using namespace std::literals;
const char * tenv {"mygrate_something"};
::unsetenv(tenv);
- BOOST_CHECK_EQUAL(MyGrate::getenv(tenv, ""), "");
- BOOST_CHECK_EQUAL(MyGrate::getenv(tenv, "default"), "default");
+ BOOST_CHECK_EQUAL(std::string_view(MyGrate::getenv(tenv, "")), ""sv);
+ BOOST_CHECK_EQUAL(std::string_view(MyGrate::getenv(tenv, "default")), "default"sv);
::setenv(tenv, "something else", 1);
- BOOST_CHECK_EQUAL(MyGrate::getenv(tenv, "default"), "something else");
+ BOOST_CHECK_EQUAL(std::string_view {MyGrate::getenv(tenv, "default")}, "something else"sv);
::unsetenv(tenv);
}
diff --git a/test/test-postgresql.cpp b/test/test-postgresql.cpp
index f1c7990..eafe5b3 100644
--- a/test/test-postgresql.cpp
+++ b/test/test-postgresql.cpp
@@ -134,7 +134,7 @@ using FloatTypes = boost::mpl::list<float, double>;
BOOST_AUTO_TEST_CASE_TEMPLATE(write_floats, T, FloatTypes)
{
MyGrate::Output::Pq::WritePqCopyStream c {s};
- c(T {1.1F});
+ c(T {static_cast<T>(1.1F)});
flush();
BOOST_REQUIRE(out);
diff --git a/test/test-rawDataReader.cpp b/test/test-rawDataReader.cpp
index 3d34bff..d10f9a1 100644
--- a/test/test-rawDataReader.cpp
+++ b/test/test-rawDataReader.cpp
@@ -152,7 +152,8 @@ BOOST_DATA_TEST_CASE(read_field_type,
bytes, exp)
{
RawDataReader rdr {bytes.data(), bytes.size()};
- BOOST_CHECK_EQUAL(rdr.readValue<enum_field_types>(1), exp);
+ const auto e {rdr.readValue<enum_field_types>(1)};
+ BOOST_CHECK_EQUAL(e, exp);
}
BOOST_AUTO_TEST_CASE(rdr_from_MARIADB_STRING)
@@ -160,7 +161,8 @@ BOOST_AUTO_TEST_CASE(rdr_from_MARIADB_STRING)
std::string buf {"test"};
MARIADB_STRING str {buf.data(), buf.length()};
RawDataReader rdr {str};
- BOOST_CHECK_EQUAL(rdr.viewValue<std::string_view>(buf.length()), buf);
+ const auto s {rdr.viewValue<std::string_view>(buf.length())};
+ BOOST_CHECK_EQUAL(s, buf);
}
using SimpleTypes = boost::mpl::list<std::byte, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t,