From 4181eac9bc6f926d24ba895bd84a53efbafd50dc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 7 Nov 2020 01:32:48 +0000 Subject: Fix metadata used for checking element name of sequence Was item, should be element. --- slicer/test/classtype.ice | 1 + slicer/test/initial/optionals-areset.xml | 8 ++++---- slicer/test/initial/seqOfClass.xml | 8 ++++---- slicer/test/serializers.cpp | 10 ++++++++++ slicer/tool/parser.cpp | 9 ++++----- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/slicer/test/classtype.ice b/slicer/test/classtype.ice index 54f4d45..cf4be61 100644 --- a/slicer/test/classtype.ice +++ b/slicer/test/classtype.ice @@ -8,6 +8,7 @@ module TestModule { int a; int b; }; + ["slicer:element:bis"] sequence Classes; }; diff --git a/slicer/test/initial/optionals-areset.xml b/slicer/test/initial/optionals-areset.xml index 54cf855..400e379 100644 --- a/slicer/test/initial/optionals-areset.xml +++ b/slicer/test/initial/optionals-areset.xml @@ -10,14 +10,14 @@ 2017-09-07 - + 3 4 - - + + 5 6 - + diff --git a/slicer/test/initial/seqOfClass.xml b/slicer/test/initial/seqOfClass.xml index 0ed2ccf..f36c599 100644 --- a/slicer/test/initial/seqOfClass.xml +++ b/slicer/test/initial/seqOfClass.xml @@ -1,11 +1,11 @@ - + 1 2 - - + + 4 5 - + diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp index 83080df..b161e7f 100644 --- a/slicer/test/serializers.cpp +++ b/slicer/test/serializers.cpp @@ -714,6 +714,16 @@ BOOST_AUTO_TEST_CASE(DeserializeXmlAbstractImpl) BOOST_CHECK_EQUAL("value", impl->testVal); } +BOOST_AUTO_TEST_CASE(DeserializeXmlIncorrectSeqElementName) +{ + std::stringstream in(R"X( + + + )X"); + BOOST_CHECK_THROW((Slicer::DeserializeAny(in)), + Slicer::IncorrectElementName); +} + BOOST_AUTO_TEST_CASE(customerModelPartCounters) { BOOST_REQUIRE_EQUAL(21, TestModule::completions); diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp index 9e9e65e..ef468e8 100644 --- a/slicer/tool/parser.cpp +++ b/slicer/tool/parser.cpp @@ -494,12 +494,12 @@ namespace Slicer { "bool matchCase)\n{\n", s->scoped()); const IceMetaData md {s->getMetaData()}; - auto iname = md.value("slicer:item:"); - if (iname) { + auto ename = md.value("slicer:element:"); + if (ename) { fprintbf(cpp, "\tif (!name.empty() && !optionalCaseEq(name, \"%s\", matchCase)) { throw " - "IncorrectElementName(name); }\n", - *iname); + "IncorrectElementName(std::string{name}); }\n", + *ename); } else { fprintbf(cpp, "\t(void)matchCase;\n"); @@ -508,7 +508,6 @@ namespace Slicer { fprintbf(cpp, "\treturn GetAnonChildRef(flt);\n}\n\n"); fprintbf(cpp, "template<> DLL_PUBLIC\n"); - auto ename = md.value("slicer:element:"); fprintbf(cpp, "const std::string ModelPartForSequence< %s >::elementName(\"%s\");\n\n", s->scoped(), ename ? *ename : "element"); -- cgit v1.2.3