From a266068bd57c2021ebe6fb6bd51e56fbd24f6cef Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 29 Sep 2016 21:46:41 +0100 Subject: Big mangle of the testing stuffs to split the test type definitions into multiple manageable files --- slicer/db/Jamfile.jam | 3 - slicer/db/testInsert.cpp | 19 ++--- slicer/db/testSelect.cpp | 5 +- slicer/db/testUpdate.cpp | 7 +- slicer/test/Jamfile.jam | 46 ++++++------ slicer/test/classes.ice | 40 ++++++++++ slicer/test/collections.ice | 17 +++++ slicer/test/conversions.cpp | 7 +- slicer/test/db.ice | 34 +++++++++ slicer/test/enums.ice | 15 ++++ slicer/test/fileStructure.cpp | 21 ------ slicer/test/fileStructure.h | 25 ------- slicer/test/inheritance.ice | 44 +++++++++++ slicer/test/json.ice | 14 ++++ slicer/test/optionals.ice | 19 +++++ slicer/test/preprocessor.cpp | 84 +++++++++++++-------- slicer/test/serializers.cpp | 38 +++++----- slicer/test/structs.ice | 34 +++++++++ slicer/test/types.ice | 167 +++--------------------------------------- slicer/test/xml.ice | 22 ++++++ 20 files changed, 366 insertions(+), 295 deletions(-) create mode 100644 slicer/test/classes.ice create mode 100644 slicer/test/collections.ice create mode 100644 slicer/test/db.ice create mode 100644 slicer/test/enums.ice delete mode 100644 slicer/test/fileStructure.cpp delete mode 100644 slicer/test/fileStructure.h create mode 100644 slicer/test/inheritance.ice create mode 100644 slicer/test/json.ice create mode 100644 slicer/test/optionals.ice create mode 100644 slicer/test/structs.ice create mode 100644 slicer/test/xml.ice diff --git a/slicer/db/Jamfile.jam b/slicer/db/Jamfile.jam index c6915ef..54677a7 100644 --- a/slicer/db/Jamfile.jam +++ b/slicer/db/Jamfile.jam @@ -32,7 +32,6 @@ path-constant me : . ; run testSelect.cpp : : : - ROOT=\"$(me)\" BOOST_TEST_DYN_LINK slicer-db slicer-db @@ -53,7 +52,6 @@ run testSelect.cpp run testInsert.cpp : : : - ROOT=\"$(me)\" BOOST_TEST_DYN_LINK slicer-db dbpp-postgresql @@ -73,7 +71,6 @@ run testInsert.cpp run testUpdate.cpp : : : - ROOT=\"$(me)\" BOOST_TEST_DYN_LINK slicer-db slicer-db diff --git a/slicer/db/testInsert.cpp b/slicer/db/testInsert.cpp index ef37e66..34a236f 100644 --- a/slicer/db/testInsert.cpp +++ b/slicer/db/testInsert.cpp @@ -8,17 +8,18 @@ #include "sqlSelectDeserializer.h" #include #include +#include // LCOV_EXCL_START BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::DateTime); BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::IsoDate); -BOOST_TEST_DONT_PRINT_LOG_VALUE(DB::Timespan); +BOOST_TEST_DONT_PRINT_LOG_VALUE(TestDatabase::Timespan); // LCOV_EXCL_STOP class StandardMockDatabase : public PQ::Mock { public: StandardMockDatabase() : PQ::Mock("user=postgres dbname=postgres", "pqmock", { - rootDir / "slicer.sql" }) + rootDir.parent_path() / "db" / "slicer.sql" }) { } }; @@ -117,13 +118,13 @@ BOOST_AUTO_TEST_CASE( fetchinsert_seq_builtins ) BOOST_AUTO_TEST_CASE( fetchinsert_seq_builtinsWithNulls ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); - DB::BuiltInSeq bis = { - DB::BuiltInsPtr(new DB::BuiltIns(true, IceUtil::Optional(), 17, 0, 129, 2.3, 4.5, "more text")), - DB::BuiltInsPtr(new DB::BuiltIns(true, 6, 18, 0, 130, 3.4, IceUtil::Optional(), "even more text")) + TestDatabase::BuiltInSeq bis = { + TestDatabase::BuiltInsPtr(new TestDatabase::BuiltIns(true, IceUtil::Optional(), 17, 0, 129, 2.3, 4.5, "more text")), + TestDatabase::BuiltInsPtr(new TestDatabase::BuiltIns(true, 6, 18, 0, 130, 3.4, IceUtil::Optional(), "even more text")) }; Slicer::SerializeAny(bis, db.get(), "builtins"); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM builtins WHERE mint IN (5, 6) ORDER BY mint")); - auto bis2 = Slicer::DeserializeAny(*sel); + auto bis2 = Slicer::DeserializeAny(*sel); BOOST_REQUIRE_EQUAL(2, bis2.size()); BOOST_REQUIRE_EQUAL(bis.front()->mint, 5); BOOST_REQUIRE_EQUAL(bis.back()->mint, 6); @@ -141,14 +142,14 @@ BOOST_AUTO_TEST_CASE( fetchinsert_seq_builtinsWithNulls ) BOOST_AUTO_TEST_CASE( insert_converted ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); - DB::SpecificTypesPtr st = new DB::SpecificTypes { + TestDatabase::SpecificTypesPtr st = new TestDatabase::SpecificTypes { {2015, 10, 16, 19, 12, 34}, {2015, 10, 16}, - new DB::Timespan(1, 2, 3, 4) + new TestDatabase::Timespan(1, 2, 3, 4) }; Slicer::SerializeAny(st, db.get(), "converted"); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM converted")); - auto st2 = Slicer::DeserializeAny(*sel); + auto st2 = Slicer::DeserializeAny(*sel); BOOST_REQUIRE_EQUAL(st->date, st2->date); BOOST_REQUIRE_EQUAL(st->dt, st2->dt); BOOST_REQUIRE_EQUAL(st->ts->days, st2->ts->days); diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp index c1e2121..5428f29 100644 --- a/slicer/db/testSelect.cpp +++ b/slicer/db/testSelect.cpp @@ -7,12 +7,13 @@ #include "sqlSelectDeserializer.h" #include #include +#include #include class StandardMockDatabase : public PQ::Mock { public: StandardMockDatabase() : PQ::Mock("user=postgres dbname=postgres", "pqmock", { - rootDir / "slicer.sql" }) + rootDir.parent_path() / "db" / "slicer.sql" }) { } }; @@ -147,7 +148,7 @@ BOOST_AUTO_TEST_CASE( select_inherit_datetime ) "SELECT dt, to_char(dt, 'YYYY-MM-DD') date, ts \ FROM test \ WHERE id = 3")); - DB::SpecificTypesPtr bi = Slicer::DeserializeAny(*sel); + TestDatabase::SpecificTypesPtr bi = Slicer::DeserializeAny(*sel); BOOST_REQUIRE_EQUAL(2015, bi->dt.year); BOOST_REQUIRE_EQUAL(3, bi->dt.month); BOOST_REQUIRE_EQUAL(27, bi->dt.day); diff --git a/slicer/db/testUpdate.cpp b/slicer/db/testUpdate.cpp index 1bf917e..624149d 100644 --- a/slicer/db/testUpdate.cpp +++ b/slicer/db/testUpdate.cpp @@ -9,12 +9,13 @@ #include "sqlUpdateSerializer.h" #include #include +#include #include class StandardMockDatabase : public PQ::Mock { public: StandardMockDatabase() : PQ::Mock("user=postgres dbname=postgres", "pqmock", { - rootDir / "slicer.sql" }) + rootDir.parent_path() / "db" / "slicer.sql" }) { } }; @@ -97,7 +98,7 @@ BOOST_AUTO_TEST_CASE( update_withNulls ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM builtins ORDER BY mint")); - auto bis = Slicer::DeserializeAny(*sel); + auto bis = Slicer::DeserializeAny(*sel); BOOST_REQUIRE_EQUAL(2, bis.size()); BOOST_REQUIRE_EQUAL("string updated", *bis[0]->mstring); BOOST_REQUIRE_EQUAL("string", *bis[1]->mstring); @@ -109,7 +110,7 @@ BOOST_AUTO_TEST_CASE( update_withNulls ) bis[1]->mdouble = IceUtil::Optional(); BOOST_TEST_CHECKPOINT("Do update"); Slicer::SerializeAny(bis, db.get(), "builtins"); - auto bis2 = Slicer::DeserializeAny(*sel); + auto bis2 = Slicer::DeserializeAny(*sel); BOOST_REQUIRE(bis2[0]->mstring); BOOST_REQUIRE(!bis2[1]->mstring); BOOST_REQUIRE(bis2[0]->mbyte); diff --git a/slicer/test/Jamfile.jam b/slicer/test/Jamfile.jam index 7bf0b05..47240c3 100644 --- a/slicer/test/Jamfile.jam +++ b/slicer/test/Jamfile.jam @@ -27,56 +27,55 @@ actions slicer bind SLICERBIN "$(SLICERBIN)" -I"$(INCLUDES)" $(2) $(1[1]) $(ALLOWICE[1]) --headerPrefix="\"\"" } -cpp stypes : - types.ice +lib typesice : + [ glob *.ice ] : - pure - ../tool//slicer - ../tool//slicer + no + . included + pthread + Ice + IceUtil + included//included + included//included + : : + pthread + Ice + IceUtil ; lib types : - types.ice - stypes + [ glob *.ice ] conversions.cpp : + ../tool//slicer + pure + ../tool//slicer . - pthread - Ice - IceUtil adhocutil + typesice boost_date_time included//included ../slicer//slicer + typesice included//included ../slicer//slicer : : . - pthread - Ice - IceUtil included//included ../slicer//slicer + typesice ; path-constant me : . ; -lib common : - helpers.cpp - fileStructure.cpp - : - adhocutil - boost_system - boost_filesystem - boost_utf - ROOT=\"$(me)\" - : : +alias common : : : : boost_filesystem boost_system BOOST_TEST_DYN_LINK boost_utf types + ROOT=\"$(me)\" ; run preprocessor.cpp @@ -100,6 +99,7 @@ run compilation.cpp ; run serializers.cpp + helpers.cpp : : : types common diff --git a/slicer/test/classes.ice b/slicer/test/classes.ice new file mode 100644 index 0000000..c85f377 --- /dev/null +++ b/slicer/test/classes.ice @@ -0,0 +1,40 @@ +#ifndef SLICER_TEST_CLASSES +#define SLICER_TEST_CLASSES + +#include + +module TestModule { + class DateTimeContainer { + [ "slicer:conversion:boost.posix_time.ptime:ptimeToDateTime:dateTimeToPTime", + "slicer:conversion:std.string:stringToDateTime:dateTimeToString:nodeclare" ] + DateTime dt; + IsoDate date; + }; + class BuiltIns { + bool mbool; + byte mbyte; + short mshort; + ["slicer:db:pkey", + "slicer:db:auto"] + int mint; + ["slicer:db:pkey"] + long mlong; + float mfloat; + double mdouble; + string mstring; + }; + [ "slicer:custommodelpart:TestModule.AbValidator" ] + class ClassType { + int a; + int b; + }; + class ClassClass { + ClassType cls; + StructType str; + ["slicer:xml:attribute"] + int simp; + }; +}; + +#endif + diff --git a/slicer/test/collections.ice b/slicer/test/collections.ice new file mode 100644 index 0000000..5ff54bd --- /dev/null +++ b/slicer/test/collections.ice @@ -0,0 +1,17 @@ +#ifndef SLICER_TEST_COLLECTIONS +#define SLICER_TEST_COLLECTIONS + +#include +#include + +module TestModule { + sequence SimpleSeq; + sequence BuiltInSeq; + sequence Classes; + sequence Structs; + dictionary ClassMap; + dictionary StructMap; +}; + +#endif + diff --git a/slicer/test/conversions.cpp b/slicer/test/conversions.cpp index af3afcd..8510089 100644 --- a/slicer/test/conversions.cpp +++ b/slicer/test/conversions.cpp @@ -1,6 +1,7 @@ #include "conversions.h" #include #include +#include #define SHORT(x) boost::numeric_cast< ::Ice::Short , int64_t >(x) @@ -90,15 +91,15 @@ namespace Slicer { } DLL_PUBLIC - ::DB::TimespanPtr + ::TestDatabase::TimespanPtr timedurationToTimespan(const boost::posix_time::time_duration & td) { - return new ::DB::Timespan(SHORT(td.hours() / 24), SHORT(td.hours() % 24), SHORT(td.minutes()), SHORT(td.seconds())); + 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 ::DB::TimespanPtr & ts) + timespanToTimeduration(const ::TestDatabase::TimespanPtr & ts) { return boost::posix_time::time_duration((ts->days * 24) + ts->hours, ts->minutes, ts->seconds); } diff --git a/slicer/test/db.ice b/slicer/test/db.ice new file mode 100644 index 0000000..a586503 --- /dev/null +++ b/slicer/test/db.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/test/enums.ice b/slicer/test/enums.ice new file mode 100644 index 0000000..a482285 --- /dev/null +++ b/slicer/test/enums.ice @@ -0,0 +1,15 @@ +#ifndef SLICER_TEST_ENUMS +#define SLICER_TEST_ENUMS + +module TestModule { + enum SomeNumbers { + One = 1, Ten = 10, FiftyFive = 55 + }; + class SomeEnums { + SomeNumbers one; + SomeNumbers two; + }; +}; + +#endif + diff --git a/slicer/test/fileStructure.cpp b/slicer/test/fileStructure.cpp deleted file mode 100644 index 53b3c2d..0000000 --- a/slicer/test/fileStructure.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "fileStructure.h" -#include -#include -#include - -FileStructure::FileStructure() : - me(selfExe), - base("types"), - bjamout("bin" / buildVariant), - root(rootDir), - included(root / "included"), - slice(fs::change_extension(root / base, ".ice")), - tmp(root / "bin" / "slicer") -{ - fs::create_directory(tmp); -} - -FileStructure::~FileStructure() -{ -} - diff --git a/slicer/test/fileStructure.h b/slicer/test/fileStructure.h deleted file mode 100644 index 4821fea..0000000 --- a/slicer/test/fileStructure.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef SLICER_TEST_FILESTRUCTURE -#define SLICER_TEST_FILESTRUCTURE - -#include -#include - -namespace fs = boost::filesystem; - -class DLL_PUBLIC FileStructure { - public: - FileStructure(); - ~FileStructure(); - - protected: - const fs::path & me; - const fs::path base; - const fs::path bjamout; - const fs::path & root; - const fs::path included; - const fs::path slice; - const fs::path tmp; -}; - -#endif - diff --git a/slicer/test/inheritance.ice b/slicer/test/inheritance.ice new file mode 100644 index 0000000..3caa2eb --- /dev/null +++ b/slicer/test/inheritance.ice @@ -0,0 +1,44 @@ +#ifndef SLICER_TEST_INHERITANCE +#define SLICER_TEST_INHERITANCE + +module TestModule { + class Base { + int a; + }; + class D1 extends Base { + int b; + }; + class D2 extends Base { + int c; + }; + class D3 extends D2 { + int d; + }; + sequence BaseSeq; + dictionary BaseMap; + class InheritanceCont { + Base b; + BaseSeq bs; + BaseMap bm; + }; + ["slicer:typeid:mytype"] + class Base2 { + int a; + }; + class D12 extends Base2 { + int b; + }; + class InheritanceCont2 { + Base2 b; + }; + ["slicer:typename:onetwo"] + class D13 extends Base2 { + int c; + }; + class InheritanceContMapped { + Base2 b; + }; +}; + +#endif + diff --git a/slicer/test/json.ice b/slicer/test/json.ice new file mode 100644 index 0000000..8dfcc60 --- /dev/null +++ b/slicer/test/json.ice @@ -0,0 +1,14 @@ +#ifndef SLICER_TEST_JSON +#define SLICER_TEST_JSON + +module TestJson { + [ "slicer:json:object" ] + dictionary Properties; + class HasProperities { + string name; + Properties props; + }; +}; + +#endif + diff --git a/slicer/test/optionals.ice b/slicer/test/optionals.ice new file mode 100644 index 0000000..63476ad --- /dev/null +++ b/slicer/test/optionals.ice @@ -0,0 +1,19 @@ +#ifndef SLICER_TEST_OPTIONALS +#define SLICER_TEST_OPTIONALS + +#include +#include +#include + +module TestModule { + class Optionals { + optional(0) int optSimple; + optional(1) StructType optStruct; + optional(2) ClassType optClass; + optional(3) Classes optSeq; + optional(4) ClassMap optDict; + }; +}; + +#endif + diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp index fadbac9..7431a2d 100644 --- a/slicer/test/preprocessor.cpp +++ b/slicer/test/preprocessor.cpp @@ -2,27 +2,69 @@ #include #include +#include #include #include +#include #include "helpers.h" -#include "fileStructure.h" namespace fs = boost::filesystem; -const unsigned int COMPONENTS_IN_TEST_ICE = 40; +typedef std::map ComponentsCount; +ComponentsCount COMPONENTS_IN_TEST_ICE = { + { "enums.ice", 2 }, + { "structs.ice", 4 }, + { "classes.ice", 4 }, + { "optionals.ice", 1 }, + { "collections.ice", 6 }, + { "inheritance.ice", 12 }, + { "interfaces.ice", 0 }, + { "json.ice", 2 }, + { "xml.ice", 2 }, + { "db.ice", 4 }, + { "types.ice", 3 } +}; -BOOST_FIXTURE_TEST_SUITE ( preprocessor, FileStructure ); +unsigned int +total() +{ + unsigned int t = 0; + for(const auto & c : COMPONENTS_IN_TEST_ICE) { + t += c.second; + } + return t; + BOOST_REQUIRE_EQUAL(40, t); +} + +void +process(Slicer::Slicer & s, const ComponentsCount::value_type & c) +{ +#if BOOST_VERSION / 100 >= 1060 + BOOST_TEST_CONTEXT(c.first) +#endif + { + s.slicePath = rootDir / c.first; + BOOST_REQUIRE_EQUAL(c.second, s.Execute()); + } +} + +void +processAll(Slicer::Slicer & s) +{ + s.includes.push_back(rootDir / "included"); + s.includes.push_back(rootDir); + for(const auto & c : COMPONENTS_IN_TEST_ICE) { + BOOST_TEST_CHECKPOINT(c.first); + process(s, c); + } + BOOST_REQUIRE_EQUAL(total(), s.Components()); +} BOOST_AUTO_TEST_CASE( slicer_test_counts_path ) { Slicer::Slicer s; - s.slicePath = slice; s.cppPath = "/dev/null"; - s.includes.push_back(included); - - auto count = s.Execute(); - BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, count); - BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, s.Components()); + processAll(s); } BOOST_AUTO_TEST_CASE( slicer_test_counts_filestar ) @@ -30,34 +72,14 @@ BOOST_AUTO_TEST_CASE( slicer_test_counts_filestar ) FILE * file = fopen("/dev/null", "a"); BOOST_REQUIRE(file); Slicer::Slicer s; - s.slicePath = slice; s.cpp = file; - s.includes.push_back(included); - - auto count = s.Execute(); - BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, count); - + processAll(s); fclose(file); } BOOST_AUTO_TEST_CASE( slicer_test_counts_nullfilestar ) { Slicer::Slicer s; - s.slicePath = slice; - s.includes.push_back(included); - - auto count = s.Execute(); - BOOST_REQUIRE_EQUAL(COMPONENTS_IN_TEST_ICE, count); + processAll(s); } -BOOST_AUTO_TEST_CASE( slicer_test_counts_interfacesOnly ) -{ - Slicer::Slicer s; - s.slicePath = root / "interfaces.ice"; - - auto count = s.Execute(); - BOOST_REQUIRE_EQUAL(0, count); -} - -BOOST_AUTO_TEST_SUITE_END(); - diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp index 65bc8cd..01c6688 100644 --- a/slicer/test/serializers.cpp +++ b/slicer/test/serializers.cpp @@ -13,9 +13,11 @@ #include #include #include +#include +#include #include #include "helpers.h" -#include "fileStructure.h" +#include #include "conversions.h" namespace fs = boost::filesystem; @@ -24,14 +26,14 @@ namespace fs = boost::filesystem; BOOST_TEST_DONT_PRINT_LOG_VALUE ( TestModule::ClassMap::iterator ) // LCOV_EXCL_STOP -class FileBased : public FileStructure { +class FileBased { public: template void verifyByFile(const fs::path & infile, const boost::function & check = NULL) { - const fs::path input = root / "initial" / infile; - const fs::path tmpf = tmp / "byFile"; + const fs::path input = rootDir / "initial" / infile; + const fs::path tmpf = binDir / "byFile"; fs::create_directory(tmpf); const fs::path output = tmpf / infile; const fs::path outputJson = tmpf / fs::change_extension(infile, "json"); @@ -68,8 +70,8 @@ class FileBased : public FileStructure { const boost::function & ifree, const boost::function & check = NULL) { - const fs::path input = root / "initial" / infile; - const fs::path tmph = tmp / "byHandler"; + const fs::path input = rootDir / "initial" / infile; + const fs::path tmph = binDir / "byHandler"; fs::create_directory(tmph); const fs::path output = tmph / infile; @@ -221,14 +223,14 @@ checkAssertEq(const T & expected, const T & actual) } void -checkEntityRef(const TestModule2::EntityRef & er) +checkEntityRef(const TestXml::EntityRef & er) { BOOST_REQUIRE_EQUAL(er.Id, 26); BOOST_REQUIRE_EQUAL(er.Name, "Hull City"); } void -checkBare(const TestModule::BareContainers & bc) +checkBare(const TestXml::BareContainers & bc) { BOOST_REQUIRE_EQUAL(bc.bareSeq.size(), 2); BOOST_REQUIRE_EQUAL(bc.bareSeq[0]->a, 1); @@ -347,7 +349,7 @@ BOOST_AUTO_TEST_CASE( simpleint_json ) BOOST_AUTO_TEST_CASE( complexClass_xmlattrAndText ) { - verifyByFile("entityref.xml", checkEntityRef); + verifyByFile("entityref.xml", checkEntityRef); } BOOST_AUTO_TEST_CASE( sequenceOfClass_xml ) @@ -422,7 +424,7 @@ BOOST_AUTO_TEST_CASE( xml_attribute_xml ) BOOST_AUTO_TEST_CASE( xml_barecontainers_xml ) { - verifyByFile("bare.xml", checkBare); + verifyByFile("bare.xml", checkBare); } BOOST_AUTO_TEST_CASE( xml_classOfEnums_xml ) @@ -462,8 +464,8 @@ BOOST_AUTO_TEST_CASE( xml_simpleArray ) BOOST_AUTO_TEST_CASE( json_streams ) { - const auto tmpf = tmp / "byStream"; - const auto inFile = root / "initial" / "inherit-c.json"; + const auto tmpf = binDir / "byStream"; + const auto inFile = rootDir / "initial" / "inherit-c.json"; const auto outFile = tmpf / "streamout.json"; boost::filesystem::create_directories(tmpf); { @@ -478,8 +480,8 @@ BOOST_AUTO_TEST_CASE( json_streams ) BOOST_AUTO_TEST_CASE( xml_streams ) { - const auto tmpf = tmp / "byStream"; - const auto inFile = root / "initial" / "inherit-b.xml"; + const auto tmpf = binDir / "byStream"; + const auto inFile = rootDir / "initial" / "inherit-b.xml"; const auto outFile = tmpf / "streamout.xml"; boost::filesystem::create_directories(tmpf); { @@ -494,10 +496,10 @@ BOOST_AUTO_TEST_CASE( xml_streams ) BOOST_AUTO_TEST_CASE( invalid_enum ) { - Slicer::DeserializerPtr jdeserializer = new Slicer::JsonFileDeserializer(root / "initial" / "invalidEnum.json"); + Slicer::DeserializerPtr jdeserializer = new Slicer::JsonFileDeserializer(rootDir / "initial" / "invalidEnum.json"); BOOST_REQUIRE_THROW(Slicer::DeserializeAnyWith(jdeserializer), Slicer::InvalidEnumerationSymbol); - Slicer::DeserializerPtr xdeserializer = new Slicer::XmlFileDeserializer(root / "initial" / "invalidEnum.xml"); + Slicer::DeserializerPtr xdeserializer = new Slicer::XmlFileDeserializer(rootDir / "initial" / "invalidEnum.xml"); BOOST_REQUIRE_THROW(Slicer::DeserializeAnyWith(xdeserializer), Slicer::InvalidEnumerationSymbol); } @@ -552,11 +554,11 @@ BOOST_FIXTURE_TEST_SUITE ( compatWrapper, FileBased ); BOOST_AUTO_TEST_CASE( any ) { BOOST_TEST_CHECKPOINT("Create folders"); - const fs::path tmpf = tmp / "compatWrapper"; + const fs::path tmpf = binDir / "compatWrapper"; fs::create_directory(tmpf); BOOST_TEST_CHECKPOINT("Figure out paths"); - const boost::filesystem::path input = root / "initial" / "builtins.xml"; + const boost::filesystem::path input = rootDir / "initial" / "builtins.xml"; const boost::filesystem::path output = tmpf / "builtins.xml"; BOOST_TEST_CHECKPOINT("Deserialize with wrapper"); diff --git a/slicer/test/structs.ice b/slicer/test/structs.ice new file mode 100644 index 0000000..e06f93b --- /dev/null +++ b/slicer/test/structs.ice @@ -0,0 +1,34 @@ +#ifndef SLICER_TEST_STRUCTS +#define SLICER_TEST_STRUCTS + +["slicer:include:conversions.h"] +module TestModule { + struct DateTime { + short year; + short month; + short day; + short hour; + short minute; + short second; + }; + [ "slicer:conversion:std.string:stringToIsoDate:isoDateToString" ] + struct IsoDate { + short year; + [ "slicer:custommodelpart:TestModule.MonthValidator" ] + short month; + short day; + }; + struct StructType { + int a; + int b; + }; + class ClassType; + struct StructStruct { + ClassType cls; + StructType str; + int simp; + }; +}; + +#endif + diff --git a/slicer/test/types.ice b/slicer/test/types.ice index bdc8da8..a48f380 100644 --- a/slicer/test/types.ice +++ b/slicer/test/types.ice @@ -1,140 +1,24 @@ +#ifndef SLICER_TEST_TYPES +#define SLICER_TEST_TYPES + [["cpp:include:boost/date_time/posix_time/posix_time_types.hpp"]] [["cpp:include:boost/date_time/posix_time/time_formatters.hpp"]] [["cpp:include:boost/date_time/posix_time/time_parsers.hpp"]] #include +#include +#include +#include +#include +#include +#include ["slicer:include:conversions.h"] module TestModule { - enum SomeNumbers { - One = 1, Ten = 10, FiftyFive = 55 - }; - struct DateTime { - short year; - short month; - short day; - short hour; - short minute; - short second; - }; - [ "slicer:conversion:std.string:stringToIsoDate:isoDateToString" ] - struct IsoDate { - short year; - [ "slicer:custommodelpart:TestModule.MonthValidator" ] - short month; - short day; - }; - class DateTimeContainer { - [ "slicer:conversion:boost.posix_time.ptime:ptimeToDateTime:dateTimeToPTime", - "slicer:conversion:std.string:stringToDateTime:dateTimeToString:nodeclare" ] - DateTime dt; - IsoDate date; - }; - class BuiltIns { - bool mbool; - byte mbyte; - short mshort; - ["slicer:db:pkey", - "slicer:db:auto"] - int mint; - ["slicer:db:pkey"] - long mlong; - float mfloat; - double mdouble; - string mstring; - }; - [ "slicer:custommodelpart:TestModule.AbValidator" ] - class ClassType { - int a; - int b; - }; - struct StructType { - int a; - int b; - }; - sequence SimpleSeq; - sequence BuiltInSeq; - sequence Classes; - sequence Structs; - dictionary ClassMap; - dictionary StructMap; - class Optionals { - optional(0) int optSimple; - optional(1) StructType optStruct; - optional(2) ClassType optClass; - optional(3) Classes optSeq; - optional(4) ClassMap optDict; - }; - class ClassClass { - ClassType cls; - StructType str; - ["slicer:xml:attribute"] - int simp; - }; - struct StructStruct { - ClassType cls; - StructType str; - int simp; - }; - class Base { - int a; - }; - class D1 extends Base { - int b; - }; - class D2 extends Base { - int c; - }; - class D3 extends D2 { - int d; - }; - sequence BaseSeq; - dictionary BaseMap; - class InheritanceCont { - Base b; - BaseSeq bs; - BaseMap bm; - }; interface IgnoreMe { int someFunction(); DontCountMe otherFileReference(); }; - ["slicer:typeid:mytype"] - class Base2 { - int a; - }; - class D12 extends Base2 { - int b; - }; - class InheritanceCont2 { - Base2 b; - }; - ["slicer:typename:onetwo"] - class D13 extends Base2 { - int c; - }; - class InheritanceContMapped { - Base2 b; - }; - struct BareContainers { - [ "slicer:xml:bare" ] - Classes bareSeq; - [ "slicer:xml:bare" ] - ClassMap bareMap; - }; - class SomeEnums { - SomeNumbers one; - SomeNumbers two; - }; -}; - -module TestJson { - [ "slicer:json:object" ] - dictionary Properties; - class HasProperities { - string name; - Properties props; - }; }; module TestModule2 { @@ -145,12 +29,6 @@ module TestModule2 { TestModule::DateTime dt; TestModule::Base base; }; - struct EntityRef { - [ "slicer:xml:attribute" ] - int Id; - [ "slicer:xml:text" ] - string Name; - }; class Conv { [ "slicer:conversion:boost.posix_time.ptime:boost.posix_time.to_iso_extended_string:boost.posix_time.time_from_string:nodeclare" ] string conv; @@ -162,30 +40,5 @@ module TestModule2 { }; }; -module DB { - [ "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/xml.ice b/slicer/test/xml.ice new file mode 100644 index 0000000..ecb50b5 --- /dev/null +++ b/slicer/test/xml.ice @@ -0,0 +1,22 @@ +#ifndef SLICER_TEST_XML +#define SLICER_TEST_XML + +#include + +module TestXml { + struct BareContainers { + [ "slicer:xml:bare" ] + TestModule::Classes bareSeq; + [ "slicer:xml:bare" ] + TestModule::ClassMap bareMap; + }; + struct EntityRef { + [ "slicer:xml:attribute" ] + int Id; + [ "slicer:xml:text" ] + string Name; + }; +}; + +#endif + -- cgit v1.2.3