26 pstring(
"pstring",
"pstringd",
"Hello World"),
27 pchar(
"pchar",
"pchard",
'H'),
28 pint(
"pint",
"pintd", -2),
29 puint(
"puint",
"puintd", 3),
30 pllong(
"pllong",
"pllongd", 2147483648),
31 pullong(
"pullong",
"pullongd", 18446744073709551615ull),
32 pdouble(
"pdouble",
"pdoubled", 1.23456),
34 pints(
"pints",
"pintsd", vector<int>(3,4)),
35 pdoubles(
"pdoubles",
"pdoublesd", vector<double>(3,4.123))
63 std::string filename =
"property_writing.tst";
83 BOOST_CHECK(
pl.save(filename,
true) );
85 BOOST_CHECK(
pl.configure(filename,
true) );
95 BOOST_CHECK_EQUAL_COLLECTIONS(
102 BOOST_CHECK_EQUAL_COLLECTIONS(
117 BOOST_CHECK(
pl.configure(filename,
false) );
120 BOOST_CHECK(
pl.save(filename,
false) );
126 BOOST_CHECK(
pl.save(filename,
true) );
127 BOOST_CHECK(
pl.configure(filename,
true) );
135 std::string filename =
"property_unknown.tst";
138 BOOST_CHECK(
pl.save(filename,
true) );
139 BOOST_CHECK( !
pl.configure(filename,
true) );
140 BOOST_CHECK(
pl.configure(filename,
false) );
147 BOOST_CHECK(
pl.save(filename,
true) );
152 BOOST_CHECK(
pl.configure(filename,
false) );
157 std::string filename =
"property_loading.cpf";
158 BOOST_REQUIRE(
pl.load(filename) );
160 BOOST_CHECK(
tc.
provides()->hasProperty(
"load1") );
161 BOOST_CHECK(
tc.
provides()->hasProperty(
"load2") );
162 BOOST_CHECK(
tc.
provides()->hasProperty(
"bag1"));
163 BOOST_CHECK(
tc.
provides()->hasProperty(
"pint2") );
164 BOOST_CHECK(
tc.
provides()->hasProperty(
"puint2") );
165 BOOST_CHECK(
tc.
provides()->hasProperty(
"pllong2") );
166 BOOST_CHECK(
tc.
provides()->hasProperty(
"pullong2") );
169 BOOST_REQUIRE( bag1.ready() );
170 BOOST_CHECK( bag1.getDescription() ==
"Bag1");
172 BOOST_CHECK_EQUAL( bag.size(), 2);
173 BOOST_CHECK( bag.find(
"bagload1"));
174 BOOST_CHECK( bag.find(
"bagload2"));
178 BOOST_REQUIRE(bagload1.ready());
179 BOOST_CHECK_EQUAL(bagload1.get(), 3);
180 BOOST_CHECK_EQUAL(bagload2.
get(),
"3 3 3");
200 std::string filename =
"property_storing.tst";
201 BOOST_REQUIRE(
pl.store(filename) );
206 BOOST_REQUIRE(
pl.load(filename) );
208 BOOST_CHECK(
tc.
provides()->hasProperty(
"pstring") );
209 BOOST_CHECK(
tc.
provides()->hasProperty(
"pchar") );
210 BOOST_CHECK(
tc.
provides()->hasProperty(
"pdouble") );
211 BOOST_CHECK(
tc.
provides()->hasProperty(
"pdoubles") );
212 BOOST_CHECK(
tc.
provides()->hasProperty(
"newbag"));
214 BOOST_REQUIRE( bag1.ready() );
215 BOOST_CHECK( bag1.getDescription() ==
"newbag doc");
217 BOOST_CHECK_EQUAL( bag.size(), 3);
218 BOOST_CHECK( bag.find(
"pdouble"));
219 BOOST_CHECK( bag.find(
"pdoubles"));
220 BOOST_CHECK( bag.find(
"pbag"));
224 BOOST_REQUIRE(bagdouble.ready());
225 BOOST_CHECK_EQUAL( bagdouble.value(), 1.23456);
226 BOOST_REQUIRE(bagvector.
ready());
227 BOOST_REQUIRE_EQUAL(bagvector.
value().size(), 3);
228 BOOST_CHECK_EQUAL(bagvector.
value()[0], 4.123);
229 BOOST_CHECK_EQUAL(bagvector.
value()[1], 4.123);
230 BOOST_CHECK_EQUAL(bagvector.
value()[2], 4.123);
Property< T > & addProperty(const std::string &name, T &attr)
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
DataSourceType get() const
Property< unsigned long long > pullong
Property< T > * getPropertyType(const std::string &name) const
Service::shared_ptr provides()
#define BOOST_AUTO_TEST_SUITE_END()
bool copyProperties(PropertyBag &target, const PropertyBag &source)
A container for holding references to properties.
BOOST_AUTO_TEST_CASE(testPropSaveLoad)
Property< double > pdouble
Property< unsigned int > puint
Property< T > & addProperty(const std::string &name, T &attr)
Property< std::vector< int > > pints
bool removeProperty(base::PropertyBase *p)
Property< std::vector< double > > pdoubles
Property< PropertyBag > pbag
base::PropertyBase * getProperty(const std::string &name) const
PropertyBag * properties()
Property< long long > pllong
Property< string > pstring