diff options
author | randomdan <randomdan@localhost> | 2014-07-03 10:58:12 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2014-07-03 10:58:12 +0000 |
commit | 7f67603d711f3ac207a21faa3c97399279f5cf52 (patch) | |
tree | 2441f4dc9f3ec33ab392d560ff78e0fce820bca0 | |
parent | Add missing unit test data (diff) | |
download | slicer-7f67603d711f3ac207a21faa3c97399279f5cf52.tar.bz2 slicer-7f67603d711f3ac207a21faa3c97399279f5cf52.tar.xz slicer-7f67603d711f3ac207a21faa3c97399279f5cf52.zip |
Fix handling of Byte data type (treat as integer)
-rw-r--r-- | slicer/test/run-slicer.cpp | 27 | ||||
-rw-r--r-- | 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,18 +21,35 @@ 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<T> p = Slicer::Deserialize<Serializer, T>(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<Serializer>(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) { BOOST_ASSERT(!opts.optSimple); @@ -86,7 +103,7 @@ main(int, char ** argv) fs::create_directory(tmp); // Execute - verify<TestModule::BuiltIns, Slicer::Xml>(root, tmp, "builtins.xml"); + verify<TestModule::BuiltIns, Slicer::Xml>(root, tmp, "builtins.xml", checkBuiltIns_valuesCorrect); verify<TestModule::Optionals, Slicer::Xml>(root, tmp, "optionals-notset.xml", checkOptionals_notset); verify<TestModule::Optionals, Slicer::Xml>(root, tmp, "optionals-areset.xml", checkOptionals_areset); verify<TestModule::InheritanceCont, Slicer::Xml>(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<Ice::Byte>(value); + v = boost::numeric_cast<Ice::Byte>(boost::lexical_cast<int>(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<Glib::ustring>(value)); + apply(boost::lexical_cast<Glib::ustring>((int)value)); } virtual void set(const Ice::Short & value) const |