00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <boost/test/unit_test.hpp>
00020 #include <boost/cstdint.hpp>
00021 #include "torc/common/Annotated.hpp"
00022
00023 namespace torc {
00024 namespace common {
00025
00026 BOOST_AUTO_TEST_SUITE(common)
00027
00028
00029 BOOST_AUTO_TEST_CASE(AnnotatedUnitTest) {
00030
00031 Annotated outer;
00032 Annotated inner;
00033
00034 boost::uint32_t key0 = 0;
00035 boost::uint32_t key1 = 1;
00036 boost::uint32_t innerkey = 2;
00037
00038 boost::uint32_t value0 = 42;
00039 boost::uint32_t innervalue = 99;
00040
00041 inner.setAnnotation(innerkey, innervalue);
00042
00043 outer.setAnnotation(key0, value0);
00044 outer.setAnnotation(key1, inner);
00045
00046 BOOST_CHECK_EQUAL(inner.hasAnnotation(innerkey), true);
00047 BOOST_CHECK_EQUAL(inner.hasAnnotation(key0), false);
00048
00049 BOOST_CHECK_EQUAL(outer.hasAnnotation(key0), true);
00050 BOOST_CHECK_EQUAL(outer.hasAnnotation(key1), true);
00051
00052 boost::uint32_t val0 = boost::any_cast<boost::uint32_t>(outer.getAnnotation(key0));
00053 BOOST_CHECK_EQUAL(val0, value0);
00054
00055 BOOST_CHECK_EQUAL(boost::any_cast<boost::uint32_t>((boost::any_cast<Annotated>(
00056 outer.getAnnotation(key1))).getAnnotation(innerkey)), innervalue);
00057
00058 outer.removeAnnotation(key0);
00059 BOOST_CHECK_EQUAL(outer.hasAnnotation(key0), false);
00060
00061 }
00062
00063 BOOST_AUTO_TEST_SUITE_END()
00064
00065 }
00066 }