From 049a43a234077cfec1fdd8609bd6f0936f1dbc51 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 21 Aug 2025 22:43:24 +0200 Subject: [PATCH 1/2] Use explicit for single param constructors --- tests/common-cleanup.hpp | 3 ++- tests/common-pg.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/common-cleanup.hpp b/tests/common-cleanup.hpp index 171a97263..46a1dbe5d 100644 --- a/tests/common-cleanup.hpp +++ b/tests/common-cleanup.hpp @@ -26,7 +26,8 @@ namespace testing::cleanup { class file_t { public: - file_t(std::string const &filename, bool remove_on_construct = true) + explicit file_t(std::string const &filename, + bool remove_on_construct = true) : m_filename(filename) { if (remove_on_construct) { diff --git a/tests/common-pg.hpp b/tests/common-pg.hpp index 999c686dd..fcf0594e8 100644 --- a/tests/common-pg.hpp +++ b/tests/common-pg.hpp @@ -37,7 +37,7 @@ namespace testing::pg { class conn_t : public pg_conn_t { public: - conn_t(connection_params_t const &connection_params) + explicit conn_t(connection_params_t const &connection_params) : pg_conn_t(connection_params, "test") { } From 9b0a5ddce39055b3cebba3d047a024f97a1d0f1d Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 21 Aug 2025 22:46:45 +0200 Subject: [PATCH 2/2] Use const where possible --- tests/common-import.hpp | 2 +- tests/common-pg.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/common-import.hpp b/tests/common-import.hpp index 532d84a7c..901df7e9c 100644 --- a/tests/common-import.hpp +++ b/tests/common-import.hpp @@ -111,7 +111,7 @@ class data_t static std::pair get_type_id(std::string const &str) { - std::string ti(str, 0, str.find(' ')); + std::string const ti(str, 0, str.find(' ')); return osmium::string_to_object_id(ti.c_str(), osmium::osm_entity_bits::nwr); } diff --git a/tests/common-pg.hpp b/tests/common-pg.hpp index fcf0594e8..d48628499 100644 --- a/tests/common-pg.hpp +++ b/tests/common-pg.hpp @@ -105,7 +105,7 @@ class tempdb_t try { connection_params_t connection_params; connection_params.set("dbname", "postgres"); - conn_t conn{connection_params}; + conn_t const conn{connection_params}; m_db_name = fmt::format("osm2pgsql-test-{}-{}", getpid(), time(nullptr)); @@ -113,7 +113,7 @@ class tempdb_t conn.exec(R"(CREATE DATABASE "{}" WITH ENCODING 'UTF8')", m_db_name); - conn_t local = connect(); + conn_t const local = connect(); local.exec("CREATE EXTENSION postgis"); local.exec("CREATE EXTENSION hstore"); init_database_capabilities(local); @@ -145,7 +145,7 @@ class tempdb_t try { connection_params_t connection_params; connection_params.set("dbname", "postgres"); - conn_t conn{connection_params}; + conn_t const conn{connection_params}; conn.exec(R"(DROP DATABASE IF EXISTS "{}")", m_db_name); } catch (...) { fprintf(stderr, "DROP DATABASE failed. Ignored.\n");