From 585b7da8f3842d75f9d2a5b423558416ab6b8d38 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 16 Oct 2015 19:36:36 +0100 Subject: Test inserted converted values --- slicer/db/slicer.sql | 4 ++++ slicer/db/testInsert.cpp | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/slicer/db/slicer.sql b/slicer/db/slicer.sql index d77c15c..e526db3 100644 --- a/slicer/db/slicer.sql +++ b/slicer/db/slicer.sql @@ -21,3 +21,7 @@ CREATE TABLE builtins( mdouble numeric(8, 5), mstring text); +CREATE TABLE Converted( + dt timestamp without time zone, + date varchar(10), + ts interval); diff --git a/slicer/db/testInsert.cpp b/slicer/db/testInsert.cpp index 9d7bf04..fcea462 100644 --- a/slicer/db/testInsert.cpp +++ b/slicer/db/testInsert.cpp @@ -8,6 +8,10 @@ #include "sqlSelectDeserializer.h" #include +BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::DateTime); +BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::IsoDate); +BOOST_TEST_DONT_PRINT_LOG_VALUE(DB::Timespan); + class StandardMockDatabase : public PQ::Mock { public: StandardMockDatabase() : PQ::Mock("user=postgres dbname=postgres", "pqmock", { @@ -59,3 +63,19 @@ BOOST_AUTO_TEST_CASE( insert_seq_builtins ) BOOST_REQUIRE_EQUAL(bis.back()->mstring, bis2.back()->mstring); } +BOOST_AUTO_TEST_CASE( insert_converted ) +{ + auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); + DB::SpecificTypesPtr st = new DB::SpecificTypes { + {2015, 10, 16, 19, 12, 34}, + {2015, 10, 16}, + {1, 2, 3, 4} + }; + Slicer::SerializeAny(st, db.get(), "converted"); + auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM converted")); + auto st2 = Slicer::DeserializeAny(*sel); + BOOST_REQUIRE_EQUAL(st->date, st2->date); + BOOST_REQUIRE_EQUAL(st->dt, st2->dt); + BOOST_REQUIRE_EQUAL(st->ts, st2->ts); +} + -- cgit v1.2.3