summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-01-09 21:36:12 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-01-09 21:36:12 +0000
commit58ea36a8c5b6deed8b2f0dc216efb5803ab87951 (patch)
treee0b76689b29cb4bc053e493ccd51b79c4d724d2e
parentName tweaks to restore compatibility with previous interface (diff)
downloadslicer-58ea36a8c5b6deed8b2f0dc216efb5803ab87951.tar.bz2
slicer-58ea36a8c5b6deed8b2f0dc216efb5803ab87951.tar.xz
slicer-58ea36a8c5b6deed8b2f0dc216efb5803ab87951.zip
Fix the compat interface and add covering test
-rw-r--r--slicer/slicer/slicer.h6
-rw-r--r--slicer/test/serializers.cpp27
2 files changed, 30 insertions, 3 deletions
diff --git a/slicer/slicer/slicer.h b/slicer/slicer/slicer.h
index c837913..196b765 100644
--- a/slicer/slicer/slicer.h
+++ b/slicer/slicer/slicer.h
@@ -17,10 +17,10 @@ namespace Slicer {
}
template <typename Deserializer, typename Object, typename ... SerializerParams>
- Object
+ IceInternal::Handle<Object>
Deserialize(SerializerParams & ... sp)
{
- return *DeserializeAny<Deserializer, IceInternal::Handle<Object>, SerializerParams...>(sp ...);
+ return DeserializeAny<Deserializer, IceInternal::Handle<Object>, SerializerParams...>(sp ...);
}
template <typename Serializer, typename Object, typename ... SerializerParams>
@@ -36,7 +36,7 @@ namespace Slicer {
void
Serialize(IceInternal::Handle<Object> object, SerializerParams & ... sp)
{
- SerializeAny(*object, sp ...);
+ SerializeAny<Serializer>(object, sp ...);
}
}
diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp
index 6151420..a13bb49 100644
--- a/slicer/test/serializers.cpp
+++ b/slicer/test/serializers.cpp
@@ -390,5 +390,32 @@ BOOST_AUTO_TEST_CASE( optionals_areset_xml )
verifyByHelper<TestModule::OptionalsPtr, Slicer::XmlDocumentDeserializer, Slicer::XmlDocumentSerializer, xmlpp::Document *>("optionals-areset.xml", readXml, writeXml, freeXml, checkOptionals_areset);
}
+BOOST_FIXTURE_TEST_SUITE ( compatWrapper, FileBased );
+
+BOOST_AUTO_TEST_CASE( any )
+{
+ BOOST_TEST_CHECKPOINT("Create folders");
+ const fs::path tmpf = tmp / "compatWrapper";
+ fs::create_directory(tmpf);
+
+ BOOST_TEST_CHECKPOINT("Figure out paths");
+ const boost::filesystem::path input = root / "initial" / "builtins.xml";
+ const boost::filesystem::path output = tmpf / "builtins.xml";
+
+ BOOST_TEST_CHECKPOINT("Deserialize with wrapper");
+ TestModule::BuiltInsPtr object = Slicer::Deserialize<Slicer::XmlFileDeserializer, TestModule::BuiltIns>(input);
+
+ BOOST_TEST_CHECKPOINT("Test object");
+ checkBuiltIns_valuesCorrect(object);
+
+ BOOST_TEST_CHECKPOINT("Serialize with wrapper");
+ Slicer::Serialize<Slicer::XmlFileSerializer>(object, output);
+
+ BOOST_TEST_CHECKPOINT("Checksum: " << input << " === " << output);
+ system(stringbf("diff -w %s %s", input, output));
+}
+
+BOOST_AUTO_TEST_SUITE_END();
+
BOOST_AUTO_TEST_SUITE_END();