diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-08-30 18:05:55 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-08-30 18:05:55 +0100 |
commit | 593e9817534a7d884164597005578da2223d089b (patch) | |
tree | d8677ed4e7cef0e7a1ef75958cfea64f4625805f /test | |
parent | Add -Wpedantic (diff) | |
download | mygrate-593e9817534a7d884164597005578da2223d089b.tar.bz2 mygrate-593e9817534a7d884164597005578da2223d089b.tar.xz mygrate-593e9817534a7d884164597005578da2223d089b.zip |
Fix up all remaining warnings
Diffstat (limited to 'test')
-rw-r--r-- | test/helpers.cpp | 1 | ||||
-rw-r--r-- | test/test-e2e.cpp | 11 | ||||
-rw-r--r-- | test/test-misc.cpp | 24 | ||||
-rw-r--r-- | test/test-postgresql.cpp | 2 | ||||
-rw-r--r-- | test/test-rawDataReader.cpp | 6 |
5 files changed, 26 insertions, 18 deletions
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, |