diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-10-19 15:38:00 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-10-19 15:38:00 +0100 |
commit | 43705039aac98e4b8065353da3f828d894dd6f00 (patch) | |
tree | 3a65a0ed58335ef1ec99c6efc162929dff789793 | |
parent | Modernize build (diff) | |
download | libdbpp-postgresql-43705039aac98e4b8065353da3f828d894dd6f00.tar.bz2 libdbpp-postgresql-43705039aac98e4b8065353da3f828d894dd6f00.tar.xz libdbpp-postgresql-43705039aac98e4b8065353da3f828d894dd6f00.zip |
Refactor to ease testing
-rw-r--r-- | Jamroot.jam | 17 | ||||
-rw-r--r-- | libpqpp/Jamfile.jam | 30 | ||||
-rw-r--r-- | libpqpp/pq-column.cpp | 2 | ||||
-rw-r--r-- | libpqpp/unittests/Jamfile.jam | 5 | ||||
-rw-r--r-- | libpqpp/unittests/testpq.cpp | 16 |
5 files changed, 46 insertions, 24 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index 9076293..5c09de9 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -1,25 +1,12 @@ import os ; +import feature : feature ; using gcc : : [ os.environ CXX ] ; using pkg-config ; -import pkg-config ; variant coverage : debug ; -project - : requirements - <cxxstd>17 - <visibility>hidden - <linkflags>"-Wl,-z,defs,--warn-once,--gc-sections" - <variant>release:<cxxflags>"-flto=2" - <variant>release:<linkflags>"-flto=2" - <variant>debug:<warnings>extra - <variant>debug:<warnings-as-errors>on - <variant>coverage:<coverage>on - ; +feature local-dbppcore : no ; build-project libpqpp ; -pkg-config.import glibmm : : <name>glibmm-2.4 ; -pkg-config.import pq : : <name>libpq ; - diff --git a/libpqpp/Jamfile.jam b/libpqpp/Jamfile.jam index d825fa5..03553f2 100644 --- a/libpqpp/Jamfile.jam +++ b/libpqpp/Jamfile.jam @@ -1,23 +1,41 @@ import package ; +import pkg-config ; lib adhocutil : : : : <include>/usr/include/adhocutil ; lib dbppcore : : : : <include>/usr/include/dbpp ; lib boost_date_time ; lib stdc++fs ; +pkg-config.import pq : : <name>libpq ; +pkg-config.import glibmm : : <name>glibmm-2.4 ; + +project + : requirements + <cxxstd>17 + <visibility>hidden + <linkflags>"-Wl,-z,defs,--warn-once,--gc-sections" + <variant>release:<cxxflags>"-flto=2" + <variant>release:<linkflags>"-flto=2" + <variant>debug:<warnings>extra + <variant>debug:<warnings-as-errors>on + <variant>coverage:<coverage>on + ; + lib dbpp-postgresql : [ glob *.cpp ] : - <library>..//glibmm - <library>..//pq + <library>glibmm + <library>pq <library>adhocutil - <library>dbppcore + <local-dbppcore>yes:<library>../..//dbppcore + <local-dbppcore>no:<library>dbppcore <library>boost_date_time <library>stdc++fs : : <include>. - <cflags>"-I`pg_config --includedir`" - <library>..//glibmm - <library>dbppcore + <use>pq + <library>glibmm + <local-dbppcore>yes:<library>../..//dbppcore + <local-dbppcore>no:<library>dbppcore ; build-project unittests ; diff --git a/libpqpp/pq-column.cpp b/libpqpp/pq-column.cpp index 4fac1ac..0753c50 100644 --- a/libpqpp/pq-column.cpp +++ b/libpqpp/pq-column.cpp @@ -77,7 +77,7 @@ PQ::Column::apply(DB::HandleField & h) const fractions * (long)pow(10, boost::posix_time::time_res_traits::num_fractional_digits() + flen1 - flen2))); } else { - h.interval(boost::posix_time::duration_from_string(value())); + h.interval(boost::posix_time::duration_from_string(val)); } break; } diff --git a/libpqpp/unittests/Jamfile.jam b/libpqpp/unittests/Jamfile.jam index 4e6cc23..7865882 100644 --- a/libpqpp/unittests/Jamfile.jam +++ b/libpqpp/unittests/Jamfile.jam @@ -15,9 +15,10 @@ run <define>ROOT=\"$(me)\" <define>BOOST_TEST_DYN_LINK <library>..//dbpp-postgresql - <library>dbpptestcore + <local-dbppcore>yes:<library>../../..//dbpptestcore + <local-dbppcore>no:<library>dbpptestcore <library>adhocutil - <library>../..//pq + <library>..//pq <library>boost_utf <library>stdc++fs ; diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp index e78a079..67ce07a 100644 --- a/libpqpp/unittests/testpq.cpp +++ b/libpqpp/unittests/testpq.cpp @@ -441,6 +441,22 @@ BOOST_AUTO_TEST_CASE( largeBlob ) } } +BOOST_AUTO_TEST_CASE( bulkPerfTest ) +{ + auto ro = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("PQmock")); + auto sel = ro->select(R"SQL(select s a, cast(s as numeric(7,1)) b, cast(s as text) c, + make_interval(secs => s) d, make_timestamp(2019,1,1,1,1,1) + make_interval(mins=>s) e, + s % 2 = 0 f + from generate_series(1, 1000) s)SQL"); + + int64_t tot = 0; + for (const auto & [a,b,c,d,e,f] : sel->as<int64_t, double, std::string_view, + boost::posix_time::time_duration, boost::posix_time::ptime, bool>()) { + tot += a + b + c.length() + d.hours() + e.time_of_day().hours() + f; + } + BOOST_REQUIRE_EQUAL(tot, 1013265); +} + BOOST_AUTO_TEST_SUITE_END(); BOOST_AUTO_TEST_CASE( connfail ) |