summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-10-14 00:08:49 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-10-14 01:27:09 +0100
commit361ff12618bbffc6b5fa7d68633a9f5bf8939d98 (patch)
tree154028eb177f814c5a6746eaf34ab6ed38fe7bb6
parentCentralize common exceptions (diff)
downloadslicer-361ff12618bbffc6b5fa7d68633a9f5bf8939d98.tar.bz2
slicer-361ff12618bbffc6b5fa7d68633a9f5bf8939d98.tar.xz
slicer-361ff12618bbffc6b5fa7d68633a9f5bf8939d98.zip
Tests for invalid enumeration values in documents.
-rw-r--r--slicer/test/initial/enum2.json1
-rw-r--r--slicer/test/initial/invalidEnum.json1
-rw-r--r--slicer/test/initial/invalidEnum.xml2
-rw-r--r--slicer/test/serializers.cpp16
4 files changed, 20 insertions, 0 deletions
diff --git a/slicer/test/initial/enum2.json b/slicer/test/initial/enum2.json
new file mode 100644
index 0000000..45bf9c6
--- /dev/null
+++ b/slicer/test/initial/enum2.json
@@ -0,0 +1 @@
+"FiftyFive"
diff --git a/slicer/test/initial/invalidEnum.json b/slicer/test/initial/invalidEnum.json
new file mode 100644
index 0000000..2081473
--- /dev/null
+++ b/slicer/test/initial/invalidEnum.json
@@ -0,0 +1 @@
+"Cheese"
diff --git a/slicer/test/initial/invalidEnum.xml b/slicer/test/initial/invalidEnum.xml
new file mode 100644
index 0000000..d6dbb1b
--- /dev/null
+++ b/slicer/test/initial/invalidEnum.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SomeNumbers>Cheese</SomeNumbers>
diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp
index 89e7d8d..a9fd479 100644
--- a/slicer/test/serializers.cpp
+++ b/slicer/test/serializers.cpp
@@ -397,6 +397,22 @@ BOOST_AUTO_TEST_CASE( xml_rootEnums_xml )
verifyByFile<TestModule::SomeNumbers, Slicer::XmlFileDeserializer>("enum.xml", checkSomeNumbers);
}
+BOOST_AUTO_TEST_CASE( json_rootEnums_json )
+{
+ verifyByFile<TestModule::SomeNumbers, Slicer::JsonFileDeserializer>("enum2.json", checkSomeNumbers);
+}
+
+BOOST_AUTO_TEST_CASE( invalid_enum )
+{
+ IceUtil::Handle<Slicer::ModelPartForRoot<TestModule::SomeNumbers>> rootmp = new Slicer::ModelPartForRoot<TestModule::SomeNumbers>();
+
+ Slicer::DeserializerPtr jdeserializer = new Slicer::JsonFileDeserializer(root / "initial" / "invalidEnum.json");
+ BOOST_REQUIRE_THROW(jdeserializer->Deserialize(rootmp), Slicer::InvalidEnumerationValue);
+
+ Slicer::DeserializerPtr xdeserializer = new Slicer::XmlFileDeserializer(root / "initial" / "invalidEnum.xml");
+ BOOST_REQUIRE_THROW(xdeserializer->Deserialize(rootmp), Slicer::InvalidEnumerationValue);
+}
+
BOOST_AUTO_TEST_SUITE_END();