From 5e1bd196b6acd6b70745ccd7f12b2fab6dd3000a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 22 Sep 2017 21:51:30 +0100 Subject: DB specific test models should be part of the DB package --- slicer/db/Jamfile.jam | 20 +++++++++++++++++++- slicer/db/testConversions.cpp | 23 +++++++++++++++++++++++ slicer/db/testInsert.cpp | 2 +- slicer/db/testModels.ice | 34 ++++++++++++++++++++++++++++++++++ slicer/db/testPatch.cpp | 2 +- slicer/db/testSelect.cpp | 2 +- slicer/db/testUpdate.cpp | 2 +- slicer/test/conversions.cpp | 16 ---------------- slicer/test/db.ice | 34 ---------------------------------- slicer/test/preprocessor.cpp | 1 - 10 files changed, 80 insertions(+), 56 deletions(-) create mode 100644 slicer/db/testConversions.cpp create mode 100644 slicer/db/testModels.ice delete mode 100644 slicer/test/db.ice diff --git a/slicer/db/Jamfile.jam b/slicer/db/Jamfile.jam index ad15a6c..b8e45cc 100644 --- a/slicer/db/Jamfile.jam +++ b/slicer/db/Jamfile.jam @@ -13,7 +13,7 @@ lib IceUtil ; lib slicer-db : [ glob *.cpp : test*.cpp ] - [ glob *.ice ] + [ glob *.ice : test*.ice ] : .. pthread @@ -30,6 +30,16 @@ lib slicer-db : path-constant me : . ; +lib testCommon : + [ glob testConversions.cpp test*.ice ] + : + ../tool//slicer + yes + ../tool//slicer + ../test//types + ../test//types + ; + run testSelect.cpp : : : BOOST_TEST_DYN_LINK @@ -43,6 +53,8 @@ run testSelect.cpp ../test//common ../slicer//slicer ../slicer//slicer + testCommon + testCommon .. slicer.sql : @@ -61,6 +73,8 @@ run testInsert.cpp ../test//common ../slicer//slicer ../slicer//slicer + testCommon + testCommon .. slicer.sql : @@ -79,6 +93,8 @@ run testPatch.cpp ../test//common ../slicer//slicer ../slicer//slicer + testCommon + testCommon .. slicer.sql ; @@ -96,6 +112,8 @@ run testUpdate.cpp ../test//common ../slicer//slicer ../slicer//slicer + testCommon + testCommon .. slicer.sql : diff --git a/slicer/db/testConversions.cpp b/slicer/db/testConversions.cpp new file mode 100644 index 0000000..893c6ae --- /dev/null +++ b/slicer/db/testConversions.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +#define SHORT(x) boost::numeric_cast< ::Ice::Short , int64_t >(x) + +namespace Slicer { + DLL_PUBLIC + ::TestDatabase::TimespanPtr + timedurationToTimespan(const boost::posix_time::time_duration & td) + { + return new ::TestDatabase::Timespan(SHORT(td.hours() / 24), SHORT(td.hours() % 24), SHORT(td.minutes()), SHORT(td.seconds())); + } + + DLL_PUBLIC + boost::posix_time::time_duration + timespanToTimeduration(const ::TestDatabase::TimespanPtr & ts) + { + return boost::posix_time::time_duration((ts->days * 24) + ts->hours, ts->minutes, ts->seconds); + } +} + diff --git a/slicer/db/testInsert.cpp b/slicer/db/testInsert.cpp index 34a236f..fec0ed7 100644 --- a/slicer/db/testInsert.cpp +++ b/slicer/db/testInsert.cpp @@ -8,7 +8,7 @@ #include "sqlSelectDeserializer.h" #include #include -#include +#include // LCOV_EXCL_START BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::DateTime); diff --git a/slicer/db/testModels.ice b/slicer/db/testModels.ice new file mode 100644 index 0000000..a586503 --- /dev/null +++ b/slicer/db/testModels.ice @@ -0,0 +1,34 @@ +#ifndef SLICER_TEST_DB +#define SLICER_TEST_DB + +#include + +module TestDatabase { + [ "slicer:conversion:boost.posix_time.time_duration:timedurationToTimespan:timespanToTimeduration" ] + class Timespan { + int days; + short hours; + short minutes; + short seconds; + }; + class SpecificTypes extends TestModule::DateTimeContainer { + Timespan ts; + }; + class BuiltIns { + optional(1) bool mbool; + optional(2) byte mbyte; + optional(3) short mshort; + ["slicer:db:pkey", + "slicer:db:auto"] + int mint; + ["slicer:db:pkey"] + long mlong; + optional(4) float mfloat; + optional(5) double mdouble; + optional(6) string mstring; + }; + sequence BuiltInSeq; +}; + +#endif + diff --git a/slicer/db/testPatch.cpp b/slicer/db/testPatch.cpp index 333b806..012f2f5 100644 --- a/slicer/db/testPatch.cpp +++ b/slicer/db/testPatch.cpp @@ -8,7 +8,7 @@ #include "sqlSelectDeserializer.h" #include #include -#include +#include // LCOV_EXCL_START BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::DateTime); diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp index 5428f29..e50047a 100644 --- a/slicer/db/testSelect.cpp +++ b/slicer/db/testSelect.cpp @@ -7,7 +7,7 @@ #include "sqlSelectDeserializer.h" #include #include -#include +#include #include class StandardMockDatabase : public PQ::Mock { diff --git a/slicer/db/testUpdate.cpp b/slicer/db/testUpdate.cpp index 624149d..29115e3 100644 --- a/slicer/db/testUpdate.cpp +++ b/slicer/db/testUpdate.cpp @@ -9,7 +9,7 @@ #include "sqlUpdateSerializer.h" #include #include -#include +#include #include class StandardMockDatabase : public PQ::Mock { diff --git a/slicer/test/conversions.cpp b/slicer/test/conversions.cpp index 9ac43e3..edeadac 100644 --- a/slicer/test/conversions.cpp +++ b/slicer/test/conversions.cpp @@ -1,7 +1,5 @@ #include "conversions.h" #include -#include -#include #define SHORT(x) boost::numeric_cast< ::Ice::Short , int64_t >(x) @@ -91,20 +89,6 @@ namespace Slicer { SHORT(tm.tm_hour), SHORT(tm.tm_min), SHORT(tm.tm_sec)}); } - DLL_PUBLIC - ::TestDatabase::TimespanPtr - timedurationToTimespan(const boost::posix_time::time_duration & td) - { - return new ::TestDatabase::Timespan(SHORT(td.hours() / 24), SHORT(td.hours() % 24), SHORT(td.minutes()), SHORT(td.seconds())); - } - - DLL_PUBLIC - boost::posix_time::time_duration - timespanToTimeduration(const ::TestDatabase::TimespanPtr & ts) - { - return boost::posix_time::time_duration((ts->days * 24) + ts->hours, ts->minutes, ts->seconds); - } - DLL_PUBLIC IceUtil::Optional str2int(const std::string & s) diff --git a/slicer/test/db.ice b/slicer/test/db.ice deleted file mode 100644 index a586503..0000000 --- a/slicer/test/db.ice +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef SLICER_TEST_DB -#define SLICER_TEST_DB - -#include - -module TestDatabase { - [ "slicer:conversion:boost.posix_time.time_duration:timedurationToTimespan:timespanToTimeduration" ] - class Timespan { - int days; - short hours; - short minutes; - short seconds; - }; - class SpecificTypes extends TestModule::DateTimeContainer { - Timespan ts; - }; - class BuiltIns { - optional(1) bool mbool; - optional(2) byte mbyte; - optional(3) short mshort; - ["slicer:db:pkey", - "slicer:db:auto"] - int mint; - ["slicer:db:pkey"] - long mlong; - optional(4) float mfloat; - optional(5) double mdouble; - optional(6) string mstring; - }; - sequence BuiltInSeq; -}; - -#endif - diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp index 7d81f5e..fbf692a 100644 --- a/slicer/test/preprocessor.cpp +++ b/slicer/test/preprocessor.cpp @@ -14,7 +14,6 @@ typedef std::map ComponentsCount; ComponentsCount COMPONENTS_IN_TEST_ICE = { { "classes.ice", 4 }, { "collections.ice", 6 }, - { "db.ice", 4 }, { "enums.ice", 2 }, { "inheritance.ice", 12 }, { "interfaces.ice", 0 }, -- cgit v1.2.3