From 361ff12618bbffc6b5fa7d68633a9f5bf8939d98 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 14 Oct 2015 00:08:49 +0100 Subject: Tests for invalid enumeration values in documents. --- slicer/test/initial/enum2.json | 1 + slicer/test/initial/invalidEnum.json | 1 + slicer/test/initial/invalidEnum.xml | 2 ++ slicer/test/serializers.cpp | 16 ++++++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 slicer/test/initial/enum2.json create mode 100644 slicer/test/initial/invalidEnum.json create mode 100644 slicer/test/initial/invalidEnum.xml 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 @@ + +Cheese 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("enum.xml", checkSomeNumbers); } +BOOST_AUTO_TEST_CASE( json_rootEnums_json ) +{ + verifyByFile("enum2.json", checkSomeNumbers); +} + +BOOST_AUTO_TEST_CASE( invalid_enum ) +{ + IceUtil::Handle> rootmp = new Slicer::ModelPartForRoot(); + + 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(); -- cgit v1.2.3