From 25e5dd996b30df3ad7ee5cf3645a4ba0873aee2f Mon Sep 17 00:00:00 2001 From: randomdan Date: Thu, 3 Jul 2014 10:58:12 +0000 Subject: Fix handling of Byte data type (treat as integer) --- slicer/test/run-slicer.cpp | 27 ++++++++++++++++++++++----- slicer/xml/serializer.cpp | 4 ++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/slicer/test/run-slicer.cpp b/slicer/test/run-slicer.cpp index 35db875..c6a1ed2 100644 --- a/slicer/test/run-slicer.cpp +++ b/slicer/test/run-slicer.cpp @@ -21,17 +21,34 @@ verify(const fs::path & root, const fs::path & tmp, const fs::path & infile, con fprintf(stderr, "%s : Deserialize\n", input.string().c_str()); IceInternal::Handle p = Slicer::Deserialize(input); - fprintf(stderr, "%s : Check1\n", input.string().c_str()); - if (check) check(*p); + if (check) { + fprintf(stderr, "%s : Check1\n", input.string().c_str()); + check(*p); + } fprintf(stderr, "%s : Serialize -> %s\n", input.string().c_str(), output.string().c_str()); Slicer::Serialize(p, output); - fprintf(stderr, "%s : Check2\n", input.string().c_str()); - if (check) check(*p); + if (check) { + fprintf(stderr, "%s : Check2\n", input.string().c_str()); + check(*p); + } fprintf(stderr, "%s : OK\n", input.string().c_str()); system(stringbf("diff -w %s %s", input, output)); } +void +checkBuiltIns_valuesCorrect(const TestModule::BuiltIns & bt) +{ + BOOST_ASSERT(bt.mbool); + BOOST_ASSERT(bt.mbyte == 4); + BOOST_ASSERT(bt.mshort == 40); + BOOST_ASSERT(bt.mint == 80); + BOOST_ASSERT(bt.mlong == 800); + BOOST_ASSERT(bt.mfloat == 3.125); + BOOST_ASSERT(bt.mdouble == 3.0625); + BOOST_ASSERT(bt.mstring == "Sample text"); +} + void checkOptionals_notset(const TestModule::Optionals & opts) { @@ -86,7 +103,7 @@ main(int, char ** argv) fs::create_directory(tmp); // Execute - verify(root, tmp, "builtins.xml"); + verify(root, tmp, "builtins.xml", checkBuiltIns_valuesCorrect); verify(root, tmp, "optionals-notset.xml", checkOptionals_notset); verify(root, tmp, "optionals-areset.xml", checkOptionals_areset); verify(root, tmp, "inherit-a.xml"); diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp index b08e274..bc593da 100644 --- a/slicer/xml/serializer.cpp +++ b/slicer/xml/serializer.cpp @@ -34,7 +34,7 @@ namespace Slicer { void set(Ice::Byte & v) const override { - v = boost::lexical_cast(value); + v = boost::numeric_cast(boost::lexical_cast(value)); } void set(Ice::Short & v) const override @@ -106,7 +106,7 @@ namespace Slicer { virtual void get(const Ice::Byte & value) const { - apply(boost::lexical_cast(value)); + apply(boost::lexical_cast((int)value)); } virtual void set(const Ice::Short & value) const -- cgit v1.2.3