From bd8aade39f74089414b5b034664c661652da826d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 6 Jan 2015 21:10:25 +0000 Subject: Revise wrapper and tests to operate on native types, not element types --- slicer/slicer/slicer.h | 8 +-- slicer/test/serializers.cpp | 170 ++++++++++++++++++++++---------------------- 2 files changed, 89 insertions(+), 89 deletions(-) diff --git a/slicer/slicer/slicer.h b/slicer/slicer/slicer.h index 878a1e6..ba0184c 100644 --- a/slicer/slicer/slicer.h +++ b/slicer/slicer/slicer.h @@ -7,10 +7,10 @@ namespace Slicer { template - IceInternal::Handle + Object Deserialize(SerializerParams & ... sp) { - IceUtil::Handle>> root = new ModelPartForRoot>(); + IceUtil::Handle> root = new ModelPartForRoot(); DeserializerPtr deserializer = new Deserializer(sp ...); deserializer->Deserialize(root); return root->GetModel(); @@ -18,9 +18,9 @@ namespace Slicer { template void - Serialize(IceInternal::Handle object, SerializerParams & ... sp) + Serialize(Object object, SerializerParams & ... sp) { - IceUtil::Handle>> root = new ModelPartForRoot>(object); + IceUtil::Handle> root = new ModelPartForRoot(object); SerializerPtr serializer = new Serializer(sp ...); serializer->Serialize(root); } diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp index 045146c..5c40302 100644 --- a/slicer/test/serializers.cpp +++ b/slicer/test/serializers.cpp @@ -19,7 +19,7 @@ namespace fs = boost::filesystem; -BOOST_TEST_DONT_PRINT_LOG_VALUE ( TestModule::ClassMap::const_iterator ) +BOOST_TEST_DONT_PRINT_LOG_VALUE ( TestModule::ClassMap::iterator ) class FileBased : public FileStructure { public: @@ -35,11 +35,11 @@ class FileBased : public FileStructure { const fs::path outputXml = tmpf / fs::change_extension(infile, "xml"); BOOST_TEST_CHECKPOINT("Deserialize: " << input); - IceInternal::Handle p = Slicer::Deserialize(input); + T p = Slicer::Deserialize(input); if (check) { BOOST_TEST_CHECKPOINT("Check1: " << input); - check(*p); + check(p); } BOOST_TEST_CHECKPOINT("Serialize " << input << " -> " << outputJson); @@ -50,7 +50,7 @@ class FileBased : public FileStructure { if (check) { BOOST_TEST_CHECKPOINT("Check2: " << input); - check(*p); + check(p); } BOOST_TEST_CHECKPOINT("Checksum: " << input << " === " << output); @@ -74,12 +74,12 @@ class FileBased : public FileStructure { Internal docRead = in(input); BOOST_TEST_CHECKPOINT("Deserialize: " << input); - IceInternal::Handle p = Slicer::Deserialize(docRead); + T p = Slicer::Deserialize(docRead); ifree(docRead); if (check) { BOOST_TEST_CHECKPOINT("Check1: " << input); - check(*p); + check(p); } BOOST_TEST_CHECKPOINT("Serialize: " << input); @@ -88,7 +88,7 @@ class FileBased : public FileStructure { if (check) { BOOST_TEST_CHECKPOINT("Check2: " << input); - check(*p); + check(p); } BOOST_TEST_CHECKPOINT("Write: " << output); @@ -101,83 +101,83 @@ class FileBased : public FileStructure { }; void -checkBuiltIns_valuesCorrect(const TestModule::BuiltIns & bt) +checkBuiltIns_valuesCorrect(const TestModule::BuiltInsPtr & bt) { - BOOST_REQUIRE_EQUAL(bt.mbool, true); - BOOST_REQUIRE_EQUAL(bt.mbyte, 4); - BOOST_REQUIRE_EQUAL(bt.mshort, 40); - BOOST_REQUIRE_EQUAL(bt.mint, 80); - BOOST_REQUIRE_EQUAL(bt.mlong, 800); - BOOST_REQUIRE_EQUAL(bt.mfloat, 3.125); - BOOST_REQUIRE_EQUAL(bt.mdouble, 3.0625); - BOOST_REQUIRE_EQUAL(bt.mstring, "Sample text"); + BOOST_REQUIRE_EQUAL(bt->mbool, true); + BOOST_REQUIRE_EQUAL(bt->mbyte, 4); + BOOST_REQUIRE_EQUAL(bt->mshort, 40); + BOOST_REQUIRE_EQUAL(bt->mint, 80); + BOOST_REQUIRE_EQUAL(bt->mlong, 800); + BOOST_REQUIRE_EQUAL(bt->mfloat, 3.125); + BOOST_REQUIRE_EQUAL(bt->mdouble, 3.0625); + BOOST_REQUIRE_EQUAL(bt->mstring, "Sample text"); } void -checkInherits_types(const TestModule::InheritanceCont & i) +checkInherits_types(const TestModule::InheritanceContPtr & i) { - BOOST_REQUIRE(i.b); - BOOST_REQUIRE(TestModule::D1Ptr::dynamicCast(i.b)); - BOOST_REQUIRE_EQUAL(TestModule::D1Ptr::dynamicCast(i.b)->a, 1); - BOOST_REQUIRE_EQUAL(TestModule::D1Ptr::dynamicCast(i.b)->b, 2); - BOOST_REQUIRE_EQUAL(i.bs.size(), 3); - BOOST_REQUIRE(i.bs[0]); - BOOST_REQUIRE(TestModule::D2Ptr::dynamicCast(i.bs[0])); - BOOST_REQUIRE_EQUAL(TestModule::D2Ptr::dynamicCast(i.bs[0])->a, 1); - BOOST_REQUIRE_EQUAL(TestModule::D2Ptr::dynamicCast(i.bs[0])->c, 100); - BOOST_REQUIRE(i.bs[1]); - BOOST_REQUIRE(TestModule::D3Ptr::dynamicCast(i.bs[1])); - BOOST_REQUIRE_EQUAL(TestModule::D3Ptr::dynamicCast(i.bs[1])->a, 2); - BOOST_REQUIRE_EQUAL(TestModule::D3Ptr::dynamicCast(i.bs[1])->c, 100); - BOOST_REQUIRE_EQUAL(TestModule::D3Ptr::dynamicCast(i.bs[1])->d, 200); - BOOST_REQUIRE(i.bs[2]); - BOOST_REQUIRE_EQUAL(i.bs[2]->a, 3); - BOOST_REQUIRE(!TestModule::D1Ptr::dynamicCast(i.bs[2])); - BOOST_REQUIRE(!TestModule::D2Ptr::dynamicCast(i.bs[2])); - BOOST_REQUIRE(!TestModule::D3Ptr::dynamicCast(i.bs[2])); - BOOST_REQUIRE_EQUAL(i.bm.size(), 3); - BOOST_REQUIRE(TestModule::D1Ptr::dynamicCast(i.bm.find(10)->second)); - BOOST_REQUIRE(TestModule::D3Ptr::dynamicCast(i.bm.find(12)->second)); - BOOST_REQUIRE(!TestModule::D1Ptr::dynamicCast(i.bm.find(14)->second)); - BOOST_REQUIRE(!TestModule::D2Ptr::dynamicCast(i.bm.find(14)->second)); - BOOST_REQUIRE(!TestModule::D3Ptr::dynamicCast(i.bm.find(14)->second)); + BOOST_REQUIRE(i->b); + BOOST_REQUIRE(TestModule::D1Ptr::dynamicCast(i->b)); + BOOST_REQUIRE_EQUAL(TestModule::D1Ptr::dynamicCast(i->b)->a, 1); + BOOST_REQUIRE_EQUAL(TestModule::D1Ptr::dynamicCast(i->b)->b, 2); + BOOST_REQUIRE_EQUAL(i->bs.size(), 3); + BOOST_REQUIRE(i->bs[0]); + BOOST_REQUIRE(TestModule::D2Ptr::dynamicCast(i->bs[0])); + BOOST_REQUIRE_EQUAL(TestModule::D2Ptr::dynamicCast(i->bs[0])->a, 1); + BOOST_REQUIRE_EQUAL(TestModule::D2Ptr::dynamicCast(i->bs[0])->c, 100); + BOOST_REQUIRE(i->bs[1]); + BOOST_REQUIRE(TestModule::D3Ptr::dynamicCast(i->bs[1])); + BOOST_REQUIRE_EQUAL(TestModule::D3Ptr::dynamicCast(i->bs[1])->a, 2); + BOOST_REQUIRE_EQUAL(TestModule::D3Ptr::dynamicCast(i->bs[1])->c, 100); + BOOST_REQUIRE_EQUAL(TestModule::D3Ptr::dynamicCast(i->bs[1])->d, 200); + BOOST_REQUIRE(i->bs[2]); + BOOST_REQUIRE_EQUAL(i->bs[2]->a, 3); + BOOST_REQUIRE(!TestModule::D1Ptr::dynamicCast(i->bs[2])); + BOOST_REQUIRE(!TestModule::D2Ptr::dynamicCast(i->bs[2])); + BOOST_REQUIRE(!TestModule::D3Ptr::dynamicCast(i->bs[2])); + BOOST_REQUIRE_EQUAL(i->bm.size(), 3); + BOOST_REQUIRE(TestModule::D1Ptr::dynamicCast(i->bm.find(10)->second)); + BOOST_REQUIRE(TestModule::D3Ptr::dynamicCast(i->bm.find(12)->second)); + BOOST_REQUIRE(!TestModule::D1Ptr::dynamicCast(i->bm.find(14)->second)); + BOOST_REQUIRE(!TestModule::D2Ptr::dynamicCast(i->bm.find(14)->second)); + BOOST_REQUIRE(!TestModule::D3Ptr::dynamicCast(i->bm.find(14)->second)); } void -checkOptionals_notset(const TestModule::Optionals & opts) +checkOptionals_notset(const TestModule::OptionalsPtr & opts) { - BOOST_REQUIRE(!opts.optSimple); - BOOST_REQUIRE(!opts.optStruct); - BOOST_REQUIRE(!opts.optClass); - BOOST_REQUIRE(!opts.optSeq); - BOOST_REQUIRE(!opts.optDict); + BOOST_REQUIRE(!opts->optSimple); + BOOST_REQUIRE(!opts->optStruct); + BOOST_REQUIRE(!opts->optClass); + BOOST_REQUIRE(!opts->optSeq); + BOOST_REQUIRE(!opts->optDict); } void -checkOptionals_areset(const TestModule::Optionals & opts) +checkOptionals_areset(const TestModule::OptionalsPtr & opts) { - BOOST_REQUIRE(opts.optSimple); - BOOST_REQUIRE_EQUAL(opts.optSimple, 4); - BOOST_REQUIRE(opts.optStruct); - BOOST_REQUIRE_EQUAL(opts.optStruct->a, 1); - BOOST_REQUIRE_EQUAL(opts.optStruct->b, 2); - BOOST_REQUIRE(opts.optClass); - BOOST_REQUIRE_EQUAL((*opts.optClass)->a, 1); - BOOST_REQUIRE_EQUAL((*opts.optClass)->b, 2); - BOOST_REQUIRE_EQUAL(opts.optSeq->size(), 2); - BOOST_REQUIRE_EQUAL((*opts.optSeq)[0]->a, 3); - BOOST_REQUIRE_EQUAL((*opts.optSeq)[0]->b, 4); - BOOST_REQUIRE_EQUAL((*opts.optSeq)[1]->a, 5); - BOOST_REQUIRE_EQUAL((*opts.optSeq)[1]->b, 6); - BOOST_REQUIRE(opts.optDict); - BOOST_REQUIRE_EQUAL(opts.optDict->size(), 2); - BOOST_REQUIRE_EQUAL(opts.optDict->find(1), opts.optDict->end()); - BOOST_REQUIRE(opts.optDict->find(10) != opts.optDict->end()); - BOOST_REQUIRE_EQUAL(opts.optDict->find(10)->second->a, 11); - BOOST_REQUIRE_EQUAL(opts.optDict->find(10)->second->b, 12); - BOOST_REQUIRE(opts.optDict->find(13) != opts.optDict->end()); - BOOST_REQUIRE_EQUAL(opts.optDict->find(13)->second->a, 14); - BOOST_REQUIRE_EQUAL(opts.optDict->find(13)->second->b, 15); + BOOST_REQUIRE(opts->optSimple); + BOOST_REQUIRE_EQUAL(opts->optSimple, 4); + BOOST_REQUIRE(opts->optStruct); + BOOST_REQUIRE_EQUAL(opts->optStruct->a, 1); + BOOST_REQUIRE_EQUAL(opts->optStruct->b, 2); + BOOST_REQUIRE(opts->optClass); + BOOST_REQUIRE_EQUAL((*opts->optClass)->a, 1); + BOOST_REQUIRE_EQUAL((*opts->optClass)->b, 2); + BOOST_REQUIRE_EQUAL(opts->optSeq->size(), 2); + BOOST_REQUIRE_EQUAL((*opts->optSeq)[0]->a, 3); + BOOST_REQUIRE_EQUAL((*opts->optSeq)[0]->b, 4); + BOOST_REQUIRE_EQUAL((*opts->optSeq)[1]->a, 5); + BOOST_REQUIRE_EQUAL((*opts->optSeq)[1]->b, 6); + BOOST_REQUIRE(opts->optDict); + BOOST_REQUIRE_EQUAL(opts->optDict->size(), 2); + BOOST_REQUIRE_EQUAL(opts->optDict->find(1), opts->optDict->end()); + BOOST_REQUIRE(opts->optDict->find(10) != opts->optDict->end()); + BOOST_REQUIRE_EQUAL(opts->optDict->find(10)->second->a, 11); + BOOST_REQUIRE_EQUAL(opts->optDict->find(10)->second->b, 12); + BOOST_REQUIRE(opts->optDict->find(13) != opts->optDict->end()); + BOOST_REQUIRE_EQUAL(opts->optDict->find(13)->second->a, 14); + BOOST_REQUIRE_EQUAL(opts->optDict->find(13)->second->b, 15); } xmlpp::Document * @@ -225,57 +225,57 @@ BOOST_FIXTURE_TEST_SUITE ( byFile, FileBased ); BOOST_AUTO_TEST_CASE( builtins_xml ) { - verifyByFile("builtins.xml", checkBuiltIns_valuesCorrect); + verifyByFile("builtins.xml", checkBuiltIns_valuesCorrect); } BOOST_AUTO_TEST_CASE( optionals_notset_xml ) { - verifyByFile("optionals-notset.xml", checkOptionals_notset); + verifyByFile("optionals-notset.xml", checkOptionals_notset); } BOOST_AUTO_TEST_CASE( optionals_areset_xml ) { - verifyByFile("optionals-areset.xml", checkOptionals_areset); + verifyByFile("optionals-areset.xml", checkOptionals_areset); } BOOST_AUTO_TEST_CASE( inherit_a_xml ) { - verifyByFile("inherit-a.xml"); + verifyByFile("inherit-a.xml"); } BOOST_AUTO_TEST_CASE( inherit_b_xml ) { - verifyByFile("inherit-b.xml", checkInherits_types); + verifyByFile("inherit-b.xml", checkInherits_types); } BOOST_AUTO_TEST_CASE( conv_datetime_xml ) { - verifyByFile("conv-datetime.xml"); + verifyByFile("conv-datetime.xml"); } BOOST_AUTO_TEST_CASE( builtins2_json ) { - verifyByFile("builtins2.json", checkBuiltIns_valuesCorrect); + verifyByFile("builtins2.json", checkBuiltIns_valuesCorrect); } BOOST_AUTO_TEST_CASE( optionals_areset2_json ) { - verifyByFile("optionals-areset2.json", checkOptionals_areset); + verifyByFile("optionals-areset2.json", checkOptionals_areset); } BOOST_AUTO_TEST_CASE( inherit_c_json ) { - verifyByFile("inherit-c.json", checkInherits_types); + verifyByFile("inherit-c.json", checkInherits_types); } BOOST_AUTO_TEST_CASE( inherit_d_json ) { - verifyByFile("inherit-d.json"); + verifyByFile("inherit-d.json"); } BOOST_AUTO_TEST_CASE( inherit_mapped_json ) { - verifyByFile("inherit-mapped.json"); + verifyByFile("inherit-mapped.json"); } BOOST_AUTO_TEST_SUITE_END(); @@ -285,17 +285,17 @@ BOOST_FIXTURE_TEST_SUITE ( byHandler, FileBased ); BOOST_AUTO_TEST_CASE( optionals_areset2_json ) { - verifyByHelper("optionals-areset2.json", readJson, writeJson, freeJson, checkOptionals_areset); + verifyByHelper("optionals-areset2.json", readJson, writeJson, freeJson, checkOptionals_areset); } BOOST_AUTO_TEST_CASE( optionals_areset_xml ) { - verifyByHelper("optionals-areset.xml", readXml, writeXml, freeXml, checkOptionals_areset); + verifyByHelper("optionals-areset.xml", readXml, writeXml, freeXml, checkOptionals_areset); } BOOST_AUTO_TEST_CASE( xml_attribute_xml ) { - verifyByFile("xmlattr.xml"); + verifyByFile("xmlattr.xml"); } BOOST_AUTO_TEST_SUITE_END(); -- cgit v1.2.3