33 #ifndef Properties_cpp 34 #define Properties_cpp 36 #include <cppunit/ui/text/TestRunner.h> 37 #include <cppunit/TextOutputter.h> 38 #include <cppunit/extensions/TestFactoryRegistry.h> 39 #include <cppunit/extensions/HelperMacros.h> 40 #include <cppunit/TestAssert.h> 42 #include <coil/Properties.h> 51 typedef std::map<std::string, std::string>::iterator
Itr;
56 :
public CppUnit::TestFixture
60 CPPUNIT_TEST(test_ctor_map);
61 CPPUNIT_TEST(test_Properties_key_value);
62 CPPUNIT_TEST(test_Properties_char);
63 CPPUNIT_TEST(test_Properties_copy);
64 CPPUNIT_TEST(test_Properties_destructor);
65 CPPUNIT_TEST(test_substitute);
66 CPPUNIT_TEST(test_Properties_destructor);
68 CPPUNIT_TEST(test_getName);
69 CPPUNIT_TEST(test_getValue);
70 CPPUNIT_TEST(test_getDefaultValue);
71 CPPUNIT_TEST(test_getLeaf);
72 CPPUNIT_TEST(test_getRoot);
74 CPPUNIT_TEST(test_getProperty);
75 CPPUNIT_TEST(test_getDefault);
76 CPPUNIT_TEST(test_setProperty);
77 CPPUNIT_TEST(test_setDefaults);
79 CPPUNIT_TEST(test_list);
80 CPPUNIT_TEST(test_load);
81 CPPUNIT_TEST(test_store);
83 CPPUNIT_TEST(test_propertyNames);
84 CPPUNIT_TEST(test_size);
85 CPPUNIT_TEST(test_findNode);
86 CPPUNIT_TEST(test_getNode);
87 CPPUNIT_TEST(test_createNode);
88 CPPUNIT_TEST(test_removeNode);
89 CPPUNIT_TEST(test_hasKey);
90 CPPUNIT_TEST(test_clear);
91 CPPUNIT_TEST(test_streamInput);
92 CPPUNIT_TEST(test_splitKeyValue);
96 CPPUNIT_TEST_SUITE_END();
127 DEFAULTS_CONF[
"rtc.openrtm.version"] =
"0.4.0";
128 DEFAULTS_CONF[
"rtc.openrtm.release"] =
"aist";
129 DEFAULTS_CONF[
"rtc.openrtm.vendor"] =
"AIST";
130 DEFAULTS_CONF[
"rtc.openrtm.author"] =
"Noriaki Ando";
131 DEFAULTS_CONF[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
132 DEFAULTS_CONF[
"rtc.manager.debug.level"] =
"PARANOID";
133 DEFAULTS_CONF[
"rtc.manager.orb"] =
"omniORB";
134 DEFAULTS_CONF[
"rtc.manager.orb.options"] =
135 "IIOPAddrPort, -ORBendPoint, giop:tcp:";
136 DEFAULTS_CONF[
"rtc.manager.arch"] =
"i386";
137 DEFAULTS_CONF[
"rtc.manager.os"] =
"FreeBSD";
138 DEFAULTS_CONF[
"rtc.manager.os.release"] =
"6.1-RELEASE";
139 DEFAULTS_CONF[
"rtc.manager.language"] =
"C++";
140 DEFAULTS_CONF[
"rtc.manager.subsystems"] =
141 "Camera, Manipulator, Force Sensor";
142 DEFAULTS_CONF[
"rtc.component.conf.path"] =
143 "C:\\\\Program\\\\ Files\\\\OpenRTM-aist";
144 DEFAULTS_CONF[
"rtc.manager.opening_message"] =
"\"Hello \" World\"";
165 string value(
"test");
171 string key0(
"manager");
173 string retkey(prop0.getName());
174 CPPUNIT_ASSERT_EQUAL(key0, retkey);
175 string retval(prop0.getValue());
176 CPPUNIT_ASSERT_EQUAL(value, retval);
182 string key1(
"manager.test.test");
186 CPPUNIT_ASSERT_EQUAL(key1, retkey);
187 retval = prop1.getValue();
188 CPPUNIT_ASSERT_EQUAL(value, retval);
201 map<string, string> defaults;
202 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
203 defaults[
"rtc.manager.arch"] =
"i386";
204 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
205 defaults[
"rtc.manager.language"] =
"C++";
206 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
207 defaults[
"rtc.manager.opening_message"] =
"Hello World";
208 defaults[
"rtc.manager.orb.name"] =
"omniORB";
209 defaults[
"rtc.manager.orb.options"] =
210 "IIOPAddrPort, -ORBendPoint, giop:tcp:";
211 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
212 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
213 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
214 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
215 defaults[
"rtc.openrtm.release"] =
"aist";
216 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
217 defaults[
"rtc.openrtm.version"] =
"0.4.0";
224 map<string, string>::iterator it;
225 it = defaults.begin();
226 for (; it != defaults.end(); ++it) {
227 string key = it->first;
228 string value = it->second;
229 CPPUNIT_ASSERT_EQUAL(value, prop.
getDefault(key));
230 CPPUNIT_ASSERT_EQUAL(value, prop.
getProperty(key));
237 const char* defaults[] = {
238 "rtc.component.conf.path",
"C:\\Program\\ Files\\OpenRTM-aist",
239 "rtc.manager.arch",
"i386",
240 "rtc.manager.debug.level",
"PARANOID",
241 "rtc.manager.language",
"C++",
242 "rtc.manager.nameserver",
"zonu.a02.aist.go.jp",
243 "rtc.manager.opening_message",
"Hello World",
244 "rtc.manager.orb.name",
"omniORB",
245 "rtc.manager.orb.options",
"IIOPAddrPort, -ORBendPoint, giop:tcp:",
246 "rtc.manager.os.name",
"FreeBSD",
247 "rtc.manager.os.release",
"6.1-RELEASE",
248 "rtc.manager.subsystems",
"Camera, Manipulator, Force Sensor",
249 "rtc.openrtm.author",
"Noriaki Ando",
250 "rtc.openrtm.release",
"aist",
251 "rtc.openrtm.vendor",
"AIST TaskIntelligence",
252 "rtc.openrtm.version",
"0.4.0",
260 for (
int i = 0; defaults[i] !=
""; i += 2) {
261 string key = defaults[i];
262 string value = defaults[i + 1];
263 CPPUNIT_ASSERT_EQUAL(value, prop.
getDefault(key));
264 CPPUNIT_ASSERT_EQUAL(value, prop.
getProperty(key));
277 map<string, string> defaults;
278 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
279 defaults[
"rtc.manager.arch"] =
"i386";
280 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
281 defaults[
"rtc.manager.language"] =
"C++";
282 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
283 defaults[
"rtc.manager.opening_message"] =
"Hello World";
284 defaults[
"rtc.manager.orb.name"] =
"omniORB";
285 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
286 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
287 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
288 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
289 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
290 defaults[
"rtc.openrtm.release"] =
"aist";
291 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
292 defaults[
"rtc.openrtm.version"] =
"0.4.0";
300 for (map<string, string>::iterator it = defaults.begin(); it != defaults.end(); it++) {
301 string key = it->first;
302 string value = it->second;
303 CPPUNIT_ASSERT_EQUAL(value, cprop.
getDefault(key));
304 CPPUNIT_ASSERT_EQUAL(value, cprop.
getProperty(key));
318 map<string, string> defaults;
319 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
320 defaults[
"rtc.manager.arch"] =
"i386";
321 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
322 defaults[
"rtc.manager.language"] =
"C++";
323 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
324 defaults[
"rtc.manager.opening_message"] =
"Hello World";
325 defaults[
"rtc.manager.orb.name"] =
"omniORB";
326 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
327 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
328 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
329 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
330 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
331 defaults[
"rtc.openrtm.release"] =
"aist";
332 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
333 defaults[
"rtc.openrtm.version"] =
"0.4.0";
337 std::vector<coil::Properties*> leaf0(prop.
getNode(
"rtc").
getLeaf());
338 CPPUNIT_ASSERT(leaf0.size() == 3);
341 delete &prop.
getNode(
"rtc.manager");
344 std::vector<coil::Properties*> leaf1(prop.
getNode(
"rtc").
getLeaf());
345 CPPUNIT_ASSERT(leaf1.size() == 2);
347 CPPUNIT_ASSERT(
"" == getval);
368 string key1 =
"key1";
369 string key1DefaultValue =
"key1-default-value";
370 string key1Value =
"key1-value";
375 string key2 =
"key2";
376 string key2DefaultValue =
"key2-default-value";
380 string key3 =
"key3";
381 string key3Value =
"key3-value";
388 CPPUNIT_ASSERT_EQUAL(key1DefaultValue, prop.
getDefault(key1));
389 CPPUNIT_ASSERT_EQUAL(key1Value, prop.
getProperty(key1));
390 CPPUNIT_ASSERT_EQUAL(key2DefaultValue, prop.
getDefault(key2));
391 CPPUNIT_ASSERT_EQUAL(key2DefaultValue, prop.
getProperty(key2));
392 CPPUNIT_ASSERT_EQUAL(EMPTY_STRING, prop.
getDefault(key3));
393 CPPUNIT_ASSERT_EQUAL(key3Value, prop.
getProperty(key3));
422 string expected_1 =
"value_1";
423 CPPUNIT_ASSERT_EQUAL(expected_1, prop.
getProperty(
"property_1"));
427 string expected_2 =
"default_2";
428 CPPUNIT_ASSERT_EQUAL(expected_2, prop.
getProperty(
"property_2"));
432 string expected_3 =
"value_3";
433 CPPUNIT_ASSERT_EQUAL(expected_3, prop.
getProperty(
"property_3"));
437 string expected_4 =
"";
438 CPPUNIT_ASSERT_EQUAL(expected_4, prop.
getProperty(
"property_4"));
465 string key1 =
"key1";
466 string key1DefaultValue =
"key1-default-value";
467 string key1Value =
"key1-value";
471 string key2 =
"key2";
472 string key2DefaultValue =
"key2-default-value";
475 string key3 =
"key3";
476 string key3Value =
"key3-value";
481 CPPUNIT_ASSERT_EQUAL(key1DefaultValue, prop.
getDefault(key1));
485 CPPUNIT_ASSERT_EQUAL(key2DefaultValue, prop.
getDefault(key2));
489 CPPUNIT_ASSERT_EQUAL(EMPTY_STRING, prop.
getDefault(key3));
493 string keyNonExist =
"key-non-exist";
494 CPPUNIT_ASSERT_EQUAL(EMPTY_STRING, prop.
getDefault(keyNonExist));
508 string oldValue =
"old-value";
509 string newValue =
"new-value";
515 CPPUNIT_ASSERT_EQUAL(oldValue, prop.
getProperty(key));
518 CPPUNIT_ASSERT_EQUAL(oldValue, prop.
setProperty(key, newValue));
521 CPPUNIT_ASSERT_EQUAL(newValue, prop.
getProperty(key));
541 "C:\\Program\\ Files\\OpenRTM-aist");
543 prop.
setProperty(
"rtc.manager.debug.level",
"PARANOID");
545 prop.
setProperty(
"rtc.manager.nameserver",
"zonu.a02.aist.go.jp");
546 prop.
setProperty(
"rtc.manager.opening_message",
"Hello World");
547 prop.
setProperty(
"rtc.manager.orb.name",
"omniORB");
549 "IIOPAddrPort, -ORBendPoint, giop:tcp:");
550 prop.
setProperty(
"rtc.manager.os.name",
"FreeBSD");
551 prop.
setProperty(
"rtc.manager.os.release",
"6.1-RELEASE");
553 "Camera, Manipulator, Force Sensor");
554 prop.
setProperty(
"rtc.openrtm.author",
"Noriaki Ando");
556 prop.
setProperty(
"rtc.openrtm.vendor",
"AIST TaskIntelligence");
559 std::ofstream outFile(
"listed.conf");
563 vector<string> expectedLines;
564 expectedLines.push_back(
"rtc.component.conf.path: C:\\\\Program\\\\ Files\\\\OpenRTM-aist");
565 expectedLines.push_back(
"rtc.manager.arch: i386");
566 expectedLines.push_back(
"rtc.manager.debug.level: PARANOID");
567 expectedLines.push_back(
"rtc.manager.language: C++");
568 expectedLines.push_back(
"rtc.manager.nameserver: zonu.a02.aist.go.jp");
569 expectedLines.push_back(
"rtc.manager.opening_message: Hello World");
570 expectedLines.push_back(
"rtc.manager.orb.name: omniORB");
571 expectedLines.push_back(
"rtc.manager.orb.options: IIOPAddrPort, -ORBendPoint, giop:tcp:");
572 expectedLines.push_back(
"rtc.manager.os.name: FreeBSD");
573 expectedLines.push_back(
"rtc.manager.os.release: 6.1-RELEASE");
574 expectedLines.push_back(
"rtc.manager.subsystems: Camera, Manipulator, Force Sensor");
575 expectedLines.push_back(
"rtc.openrtm.author: Noriaki Ando");
576 expectedLines.push_back(
"rtc.openrtm.release: aist");
577 expectedLines.push_back(
"rtc.openrtm.vendor: AIST TaskIntelligence");
578 expectedLines.push_back(
"rtc.openrtm.version: 0.4.0");
580 vector<string> storedLines;
581 std::ifstream inFile(
"listed.conf");
583 while (getline(inFile, str))
585 storedLines.push_back(str);
590 sort(expectedLines.begin(), expectedLines.end());
591 sort(storedLines.begin(), storedLines.end());
592 CPPUNIT_ASSERT_EQUAL(expectedLines.size(), storedLines.size());
593 for (vector<string>::size_type i = 0; i < expectedLines.size(); i++)
595 CPPUNIT_ASSERT_EQUAL(expectedLines[i], storedLines[i]);
612 std::ifstream ifl(
"defaults.conf");
617 map<string, string>::iterator expected;
618 for (expected = DEFAULTS_CONF.begin();
619 expected != DEFAULTS_CONF.end(); expected++) {
620 string key = expected->first;
621 string value = expected->second;
622 CPPUNIT_ASSERT_EQUAL(value, prop.
getProperty(key));
645 "C:\\Program\\ Files\\OpenRTM-aist");
647 prop.
setProperty(
"rtc.manager.debug.level",
"PARANOID");
649 prop.
setProperty(
"rtc.manager.nameserver",
"zonu.a02.aist.go.jp");
650 prop.
setProperty(
"rtc.manager.opening_message",
"Hello World");
651 prop.
setProperty(
"rtc.manager.orb.name",
"omniORB");
653 "IIOPAddrPort, -ORBendPoint, giop:tcp:");
654 prop.
setProperty(
"rtc.manager.os.name",
"FreeBSD");
655 prop.
setProperty(
"rtc.manager.os.release",
"6.1-RELEASE");
657 "Camera, Manipulator, Force Sensor");
658 prop.
setProperty(
"rtc.openrtm.author",
"Noriaki Ando");
660 prop.
setProperty(
"rtc.openrtm.vendor",
"AIST TaskIntelligence");
664 std::ofstream outFile(
"stored.conf");
665 prop.
store(outFile,
"stored data");
669 vector<string> expectedLines;
670 expectedLines.push_back(
"# stored data");
671 expectedLines.push_back(
"rtc.component.conf.path: C:\\\\Program\\\\ Files\\\\OpenRTM-aist");
672 expectedLines.push_back(
"rtc.manager.arch: i386");
673 expectedLines.push_back(
"rtc.manager.debug.level: PARANOID");
674 expectedLines.push_back(
"rtc.manager.language: C++");
675 expectedLines.push_back(
"rtc.manager.nameserver: zonu.a02.aist.go.jp");
676 expectedLines.push_back(
"rtc.manager.opening_message: Hello World");
677 expectedLines.push_back(
"rtc.manager.orb.name: omniORB");
678 expectedLines.push_back(
"rtc.manager.orb.options: IIOPAddrPort, -ORBendPoint, giop:tcp:");
679 expectedLines.push_back(
"rtc.manager.os.name: FreeBSD");
680 expectedLines.push_back(
"rtc.manager.os.release: 6.1-RELEASE");
681 expectedLines.push_back(
"rtc.manager.subsystems: Camera, Manipulator, Force Sensor");
682 expectedLines.push_back(
"rtc.openrtm.author: Noriaki Ando");
683 expectedLines.push_back(
"rtc.openrtm.release: aist");
684 expectedLines.push_back(
"rtc.openrtm.vendor: AIST TaskIntelligence");
685 expectedLines.push_back(
"rtc.openrtm.version: 0.4.0");
686 expectedLines.push_back(
"hello: \\tHello\\t");
689 vector<string> storedLines;
690 std::ifstream inFile(
"stored.conf");
692 while (getline(inFile, str)) {
693 storedLines.push_back(str);
698 sort(expectedLines.begin(), expectedLines.end());
699 sort(storedLines.begin(), storedLines.end());
700 CPPUNIT_ASSERT_EQUAL(expectedLines.size(), storedLines.size());
701 for (vector<string>::size_type i = 0; i < expectedLines.size(); i++) {
702 CPPUNIT_ASSERT_EQUAL(expectedLines[i], storedLines[i]);
739 CPPUNIT_ASSERT_EQUAL(3, (
int) keys.size());
740 CPPUNIT_ASSERT(
find(keys.begin(), keys.end(),
"property_01")
742 CPPUNIT_ASSERT(
find(keys.begin(), keys.end(),
"property_02")
744 CPPUNIT_ASSERT(
find(keys.begin(), keys.end(),
"property_03")
759 string value(
"test");
763 string key0(
"manager");
765 string retkey(prop0.getName());
766 CPPUNIT_ASSERT_EQUAL(key0, retkey);
770 string key1(
"manager.hoge");
773 CPPUNIT_ASSERT_EQUAL(key1, retkey);
786 string key(
"manager");
787 string value(
"test.test");
791 string retval(
prop.getValue());
792 CPPUNIT_ASSERT_EQUAL(value, retval);
806 string key(
"property_1");
807 string value(
"default_1");
812 string retval(prop.
getNode(key.c_str()).getDefaultValue());
813 CPPUNIT_ASSERT_EQUAL(value, retval);
825 map<string, string> defaults;
826 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
827 defaults[
"rtc.manager.arch"] =
"i386";
828 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
829 defaults[
"rtc.manager.language"] =
"C++";
830 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
831 defaults[
"rtc.manager.opening_message"] =
"Hello World";
832 defaults[
"rtc.manager.orb.name"] =
"omniORB";
833 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
834 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
835 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
836 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
837 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
838 defaults[
"rtc.openrtm.release"] =
"aist";
839 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
840 defaults[
"rtc.openrtm.version"] =
"0.4.0";
846 std::vector<coil::Properties*> leaf(prop.
getNode(
"rtc").
getLeaf());
847 CPPUNIT_ASSERT(leaf[1]->getProperty(
"arch") ==
"i386");
848 CPPUNIT_ASSERT(leaf[1]->getProperty(
"debug.level") ==
"PARANOID");
860 map<string, string> defaults;
861 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
862 defaults[
"rtc.manager.arch"] =
"i386";
863 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
864 defaults[
"rtc.manager.language"] =
"C++";
865 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
866 defaults[
"rtc.manager.opening_message"] =
"Hello World";
867 defaults[
"rtc.manager.orb.name"] =
"omniORB";
868 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
869 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
870 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
871 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
872 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
873 defaults[
"rtc.openrtm.release"] =
"aist";
874 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
875 defaults[
"rtc.openrtm.version"] =
"0.4.0";
882 CPPUNIT_ASSERT(root->getProperty(
"arch") ==
"i386");
883 CPPUNIT_ASSERT(root->getProperty(
"debug.level") ==
"PARANOID");
895 map<string, string> defaults;
896 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
897 defaults[
"rtc.manager.arch"] =
"i386";
898 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
899 defaults[
"rtc.manager.language"] =
"C++";
900 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
901 defaults[
"rtc.manager.opening_message"] =
"Hello World";
902 defaults[
"rtc.manager.orb.name"] =
"omniORB";
903 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
904 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
905 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
906 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
907 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
908 defaults[
"rtc.openrtm.release"] =
"aist";
909 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
910 defaults[
"rtc.openrtm.version"] =
"0.4.0";
916 const string& retval0(prop0[
"rtc.manager.arch"]);
917 CPPUNIT_ASSERT(retval0 ==
"i386");
923 string retval1(prop1[
"rtc.manager.arch"]);
924 CPPUNIT_ASSERT(retval1 ==
"i386");
937 const char* defaults[] = {
938 "rtc.component.conf.path",
"C:\\Program\\ Files\\OpenRTM-aist",
939 "rtc.manager.arch",
"i386",
940 "rtc.manager.debug.level",
"PARANOID",
941 "rtc.manager.language",
"C++",
942 "rtc.manager.nameserver",
"zonu.a02.aist.go.jp",
943 "rtc.manager.opening_message",
"Hello World",
944 "rtc.manager.orb.name",
"omniORB",
945 "rtc.manager.orb.options",
"IIOPAddrPort, -ORBendPoint, giop:tcp:",
946 "rtc.manager.os.name",
"FreeBSD",
947 "rtc.manager.os.release",
"6.1-RELEASE",
948 "rtc.manager.subsystems",
"Camera, Manipulator, Force Sensor",
949 "rtc.openrtm.author",
"Noriaki Ando",
950 "rtc.openrtm.release",
"aist",
951 "rtc.openrtm.vendor",
"AIST TaskIntelligence",
952 "rtc.openrtm.version",
"0.4.0",
962 for (
int i = 0; defaults[i] !=
""; i += 2) {
963 string key = defaults[i];
964 string value = defaults[i + 1];
965 CPPUNIT_ASSERT_EQUAL(value, prop.
getDefault(key));
978 map<string, string> defaults;
979 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
980 defaults[
"rtc.manager.arch"] =
"i386";
981 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
982 defaults[
"rtc.manager.language"] =
"C++";
983 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
984 defaults[
"rtc.manager.opening_message"] =
"Hello World";
985 defaults[
"rtc.manager.orb.name"] =
"omniORB";
986 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
987 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
988 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
989 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
990 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
991 defaults[
"rtc.openrtm.release"] =
"aist";
992 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
993 defaults[
"rtc.openrtm.version"] =
"0.4.0";
998 CPPUNIT_ASSERT(15 == prop.
size());
1002 string newValue =
"new-value";
1004 CPPUNIT_ASSERT(16 == prop.
size());
1016 map<string, string> defaults;
1017 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
1018 defaults[
"rtc.manager.arch"] =
"i386";
1019 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
1020 defaults[
"rtc.manager.language"] =
"C++";
1021 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
1022 defaults[
"rtc.manager.opening_message"] =
"Hello World";
1023 defaults[
"rtc.manager.orb.name"] =
"omniORB";
1024 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
1025 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
1026 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
1027 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
1028 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
1029 defaults[
"rtc.openrtm.release"] =
"aist";
1030 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
1031 defaults[
"rtc.openrtm.version"] =
"0.4.0";
1039 CPPUNIT_ASSERT(prop.
findNode(
"rtc.manager") != NULL);
1042 CPPUNIT_ASSERT(prop.
findNode(
"manager") == NULL);
1043 CPPUNIT_ASSERT(prop.
findNode(
"rtc.MANAGER") == NULL);
1055 map<string, string> defaults;
1056 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
1057 defaults[
"rtc.manager.arch"] =
"i386";
1058 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
1059 defaults[
"rtc.manager.language"] =
"C++";
1060 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
1061 defaults[
"rtc.manager.opening_message"] =
"Hello World";
1062 defaults[
"rtc.manager.orb.name"] =
"omniORB";
1063 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
1064 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
1065 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
1066 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
1067 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
1068 defaults[
"rtc.openrtm.release"] =
"aist";
1069 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
1070 defaults[
"rtc.openrtm.version"] =
"0.4.0";
1077 CPPUNIT_ASSERT(prop.
getNode(
"rtc.manager").
getProperty(
"debug.level") ==
"PARANOID");
1081 CPPUNIT_ASSERT(getval ==
"");
1094 map<string, string> defaults;
1095 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
1096 defaults[
"rtc.manager.arch"] =
"i386";
1097 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
1098 defaults[
"rtc.manager.language"] =
"C++";
1099 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
1100 defaults[
"rtc.manager.opening_message"] =
"Hello World";
1101 defaults[
"rtc.manager.orb.name"] =
"omniORB";
1102 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
1103 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
1104 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
1105 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
1106 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
1107 defaults[
"rtc.openrtm.release"] =
"aist";
1108 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
1109 defaults[
"rtc.openrtm.version"] =
"0.4.0";
1115 CPPUNIT_ASSERT(prop.
removeNode(
"rtc.manager") == NULL);
1121 CPPUNIT_ASSERT(prop.
findNode(
"rtc.manager") == NULL);
1125 CPPUNIT_ASSERT(getval0 ==
"");
1137 map<string, string> defaults;
1138 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
1139 defaults[
"rtc.manager.arch"] =
"i386";
1140 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
1141 defaults[
"rtc.manager.language"] =
"C++";
1142 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
1143 defaults[
"rtc.manager.opening_message"] =
"Hello World";
1144 defaults[
"rtc.manager.orb.name"] =
"omniORB";
1145 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
1146 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
1147 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
1148 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
1149 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
1150 defaults[
"rtc.openrtm.release"] =
"aist";
1151 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
1152 defaults[
"rtc.openrtm.version"] =
"0.4.0";
1158 CPPUNIT_ASSERT(prop.
hasKey(
"rtc") != NULL);
1161 CPPUNIT_ASSERT(prop.
hasKey(
"hoge") == NULL);
1164 CPPUNIT_ASSERT(prop.
getNode(
"rtc").
hasKey(
"manager") != NULL);
1179 map<string, string> defaults;
1180 defaults[
"rtc.component.conf.path"] =
"C:\\Program\\ Files\\OpenRTM-aist";
1181 defaults[
"rtc.manager.arch"] =
"i386";
1182 defaults[
"rtc.manager.debug.level"] =
"PARANOID";
1183 defaults[
"rtc.manager.language"] =
"C++";
1184 defaults[
"rtc.manager.nameserver"] =
"zonu.a02.aist.go.jp";
1185 defaults[
"rtc.manager.opening_message"] =
"Hello World";
1186 defaults[
"rtc.manager.orb.name"] =
"omniORB";
1187 defaults[
"rtc.manager.orb.options"] =
"IIOPAddrPort, -ORBendPoint, giop:tcp:";
1188 defaults[
"rtc.manager.os.name"] =
"FreeBSD";
1189 defaults[
"rtc.manager.os.release"] =
"6.1-RELEASE";
1190 defaults[
"rtc.manager.subsystems"] =
"Camera, Manipulator, Force Sensor";
1191 defaults[
"rtc.openrtm.author"] =
"Noriaki Ando";
1192 defaults[
"rtc.openrtm.release"] =
"aist";
1193 defaults[
"rtc.openrtm.vendor"] =
"AIST TaskIntelligence";
1194 defaults[
"rtc.openrtm.version"] =
"0.4.0";
1202 CPPUNIT_ASSERT(prop.
findNode(
"rtc.manager.os.name") == NULL);
1203 CPPUNIT_ASSERT(prop.
findNode(
"rtc.manager.os.release") == NULL);
1206 CPPUNIT_ASSERT(prop.
findNode(
"rtc.manager.arch") != NULL);
1207 CPPUNIT_ASSERT(prop.
findNode(
"rtc.manager.orb") != NULL);
1211 CPPUNIT_ASSERT(prop.
findNode(
"rtc.manager.os") == NULL);
1212 CPPUNIT_ASSERT(prop.
findNode(
"rtc.manager") == NULL);
1213 CPPUNIT_ASSERT(prop.
findNode(
"rtc.openrtm") == NULL);
1214 CPPUNIT_ASSERT(prop.
findNode(
"rtc.component") == NULL);
1215 CPPUNIT_ASSERT(prop.
findNode(
"rtc") == NULL);
1242 string key1 =
"key1";
1243 string key1DefaultValue =
"key1-default-value";
1244 string key1Value =
"key1-value";
1248 string key2 =
"key2";
1249 string key2DefaultValue =
"key2-default-value";
1252 string key3 =
"key3";
1253 string key3Value =
"key3-value";
1260 CPPUNIT_ASSERT(! prop.
createNode(key1.c_str()));
1266 CPPUNIT_ASSERT(! prop.
createNode(key2.c_str()));
1272 CPPUNIT_ASSERT(! prop.
createNode(key3.c_str()));
1278 string keyNonExist =
"key-non-exist";
1279 CPPUNIT_ASSERT(prop.
createNode(keyNonExist.c_str()));
1303 string keyA1 =
"keyA1";
1304 string keyA1DefaultValue =
"keyA1-default-value";
1305 string keyA1Value =
"keyA1-value";
1309 string keyA2 =
"keyA2";
1310 string keyA2DefaultValue =
"keyA2-default-value";
1313 string keyA3 =
"keyA3";
1314 string keyA3Value =
"keyA3-value";
1320 string keyB1 =
"keyB1";
1321 string keyB1DefaultValue =
"keyB1-default-value";
1322 string keyB1Value =
"keyB1-value";
1326 string keyB2 =
"keyB2";
1327 string keyB2DefaultValue =
"keyB2-default-value";
1330 string keyB3 =
"keyB3";
1331 string keyB3Value =
"keyB3-value";
1337 string keyCommon =
"keyCommon";
1338 string keyCommonValueA =
"keyCommon-value-A";
1339 string keyCommonValueB =
"keyCommon-value-B";
1349 CPPUNIT_ASSERT_EQUAL(keyA1DefaultValue, propA.
getDefault(keyA1));
1350 CPPUNIT_ASSERT_EQUAL(keyA1Value, propA.
getProperty(keyA1));
1351 CPPUNIT_ASSERT_EQUAL(keyA2DefaultValue, propA.
getDefault(keyA2));
1352 CPPUNIT_ASSERT_EQUAL(keyA2DefaultValue, propA.
getProperty(keyA2));
1353 CPPUNIT_ASSERT_EQUAL(EMPTY_STRING, propA.
getDefault(keyA3));
1354 CPPUNIT_ASSERT_EQUAL(keyA3Value, propA.
getProperty(keyA3));
1357 CPPUNIT_ASSERT_EQUAL(EMPTY_STRING, propA.
getDefault(keyB1));
1358 CPPUNIT_ASSERT_EQUAL(keyB1Value, propA.
getProperty(keyB1));
1359 CPPUNIT_ASSERT_EQUAL(EMPTY_STRING, propA.
getDefault(keyB2));
1360 CPPUNIT_ASSERT_EQUAL(keyB2DefaultValue, propA.
getProperty(keyB2));
1361 CPPUNIT_ASSERT_EQUAL(EMPTY_STRING, propA.
getDefault(keyB3));
1362 CPPUNIT_ASSERT_EQUAL(keyB3Value, propA.
getProperty(keyB3));
1365 CPPUNIT_ASSERT_EQUAL(keyCommonValueB, propA.
getProperty(keyCommon));
1392 void splitKeyValue_protected(
const std::string& str,
1393 std::string& key, std::string& value)
1395 splitKeyValue(str, key, value);
1399 string keyAndValue =
" property_name : C:\\abc\\pqr.xyz ";
1403 prop.splitKeyValue_protected(keyAndValue, key, value);
1407 string expectedKey(
"property_name");
1408 CPPUNIT_ASSERT_EQUAL(expectedKey, key);
1410 string expectedValue(
"C:\\abc\\pqr.xyz");
1411 CPPUNIT_ASSERT_EQUAL(expectedValue, value);
1425 int main(
int argc,
char* argv[])
1438 std::string arg(argv[i]);
1439 std::string next_arg;
1440 if (i + 1 < argc) next_arg = argv[i + 1];
1443 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
1456 ofs.open(fname.c_str());
1458 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
1459 if ( arg ==
"--cerr" ) { target = 1;
break; }
1460 if ( arg ==
"--xsl" )
1462 if (next_arg ==
"") xsl =
"default.xsl";
1463 else xsl = next_arg;
1465 if ( arg ==
"--namespace" )
1469 std::cerr <<
"no namespace specified" << std::endl;
1479 CppUnit::TextUi::TestRunner runner;
1481 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
1483 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
1484 CppUnit::Outputter* outputter = 0;
1485 std::ostream* stream = target ? &std::cerr : &std::cout;
1489 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
1492 std::cout <<
"XML_OUT" << std::endl;
1493 outputter =
new CppUnit::XmlOutputter(&runner.result(),
1495 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
1498 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
1501 runner.setOutputter(outputter);
1506 #endif // Properties_cpp void test_findNode()
findNode()メソッドのテスト
const std::vector< Properties * > & getLeaf(void) const
Get elements of leaf.
int main(int argc, char **argv)
CPPUNIT_TEST_SUITE_REGISTRATION(Properties::PropertiesTests)
void test_hasKey()
hasKey()メソッドのテスト
void test_list()
list()メソッドのテスト
const char * getName(void) const
Get Names.
void test_Properties_destructor()
~Properties(void)デストラクタのテスト
void test_substitute()
=演算子(代入演算子)のテスト
void clear(void)
Clear the children.
void store(std::ostream &out, const std::string &header)
Stores property list to the output stream.
void test_getNode()
getNode()メソッドのテスト
void test_getProperty()
getProperty()メソッドのテスト
void test_ctor_map()
Properties(std::map<string, string>&)コンストラクタのテスト
virtual void setUp()
Test initialization.
void test_clear()
clear()メソッドのテスト
std::map< std::string, std::string >::iterator Itr
Properties * hasKey(const char *key) const
Check whether key exists in the children.
void test_propertyNames()
propertyNames()メソッドのテスト
void list(std::ostream &out)
Prints this property list out to the specified output stream.
void test_operator()
operator[]()メソッドのテスト
void test_getRoot()
getRoot(void)メソッドのテスト
PropertiesTests()
Constructor.
map< string, string > DEFAULTS_CONF
void setDefaults(const char *defaults[], long num=LONG_MAX)
Set a default value together in the property list.
void test_getValue()
getValue(void)メソッドのテスト
CORBA::Long find(const CorbaSequence &seq, Functor f)
Return the index of CORBA sequence element that functor matches.
void test_load()
load()メソッドのテスト
void test_getName()
getName(void)メソッドのテスト
std::string setProperty(const std::string &key, const std::string &value)
Set a value associated with key in the property list.
bool createNode(const std::string &key)
Create newly node of Properties.
void test_Properties_key_value()
Properties(const char* key = "", const char* value = "")コンストラクタのテスト
Properties * removeNode(const char *leaf_name)
Remove node of Properties.
Properties *const findNode(const std::string &key) const
Get node of properties.
void load(std::istream &inStream)
Loads property list that consists of key:value from input stream.
void test_removeNode()
removeNode()メソッドのテスト
void test_createNode()
createNode()のテスト
void test_store()
store()メソッドのテスト
void test_setProperty()
setProperty()メソッドのテスト
prop
Organization::get_organization_property ();.
Class represents a set of properties.
void test_size()
size()メソッドのテスト
void test_getDefaultValue()
getDefaultValue(void)メソッドのテスト
const char * getValue(void) const
Get values.
void test_getLeaf()
getLeaf(void)メソッドのテスト
int size(void) const
Get the number of Properties.
void test_splitKeyValue()
splitKeyValue()メソッドのテスト
~PropertiesTests()
Destructor.
void test_setDefaults()
setDefaults()メソッドのテスト
std::vector< std::string > propertyNames(void) const
Return an vector of all the keys in this property.
Properties & getNode(const std::string &key)
Get node of properties.
virtual void tearDown()
Test finalization.
const std::string & getDefault(const std::string &key) const
Get the default values with specified key.
void test_Properties_char()
coil::Properties * m_prop
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.
std::string setDefault(const std::string &key, const std::string &value)
Set a default value associated with key in the property list.
void test_streamInput()
<<演算子のテスト
void test_Properties_copy()
Properties(const Properties& prop)コピーコンストラクタのテスト
const Properties * getRoot(void) const
Get root element.
void test_getDefault()
getDefault()のテスト