48 if (attributeName ==
"description")
49 return "A dummy component, which does nothing.";
62 static void Test_DummyComponent_CreateComponent()
68 component.
IsNULL() ==
false);
74 static void Test_DummyComponent_GetSetParent()
93 static void Test_DummyComponent_AddChild_Sets_Parent()
107 static void Test_DummyComponent_AddChildren_Count()
125 static void Test_DummyComponent_Add_Tree_Of_Children()
142 static void Test_DummyComponent_RemoveChild()
166 "there should still be 2 child components in dummyChildA",
172 static void Test_DummyComponent_AddChild_UniqueName()
220 static void Test_DummyComponent_GeneratePath()
245 static void Test_DummyComponent_GenerateShortestPossiblePath()
273 static void Test_DummyComponent_LookupPath()
281 component1.
IsNULL() ==
true);
285 component2 == dummyA);
297 component3 == dummyA);
301 component4.
IsNULL() ==
true);
305 component5 == child);
309 component6 == childchild);
312 static void Test_DummyComponent_FindPathByPartialMatch()
347 vector<string> matches;
361 matches[0],
"root.machine1.pcibus0");
363 matches[1],
"root.machine1.pcibus1");
365 matches[2],
"root.machine2.pcibus0");
371 matches[0],
"root.machine1");
377 matches[0],
"root.machine2.pcibus0");
384 static void Test_DummyComponent_GetUnknownVariable()
392 static void Test_DummyComponent_NonexistantMethodNotReexecutable()
401 static void Test_DummyComponent_Clone_Basic()
408 dummyChildA->
AddChild(dummyChildA1);
409 dummyChildA->
AddChild(dummyChildA2);
421 originalChecksum == cloneChecksum);
425 Checksum originalChecksumAfterModifyingOriginal;
426 dummy->
AddChecksum(originalChecksumAfterModifyingOriginal);
427 Checksum cloneChecksumAfterModifyingOriginal;
428 clone->
AddChecksum(cloneChecksumAfterModifyingOriginal);
431 originalChecksum != originalChecksumAfterModifyingOriginal);
433 cloneChecksum == cloneChecksumAfterModifyingOriginal);
437 Checksum originalChecksumAfterModifyingClone;
438 dummy->
AddChecksum(originalChecksumAfterModifyingClone);
439 Checksum cloneChecksumAfterModifyingClone;
440 clone->
AddChecksum(cloneChecksumAfterModifyingClone);
443 "clone has been modified",
444 originalChecksumAfterModifyingClone ==
445 originalChecksumAfterModifyingOriginal);
448 cloneChecksumAfterModifyingClone ==
449 originalChecksumAfterModifyingOriginal);
452 class DummyComponentWithAllVariableTypes
456 DummyComponentWithAllVariableTypes()
478 m_string =
"some value";
481 m_uint32 = 0x98f8aa01;
482 m_uint64 = ((uint64_t)0xf8192929 << 32) | 0x30300a0a;
491 return new DummyComponentWithAllVariableTypes();
506 static void Test_DummyComponent_Clone_AllVariableTypes()
526 originalChecksum == cloneChecksum);
530 Checksum originalChecksumAfterModifyingOriginal;
531 dummy->
AddChecksum(originalChecksumAfterModifyingOriginal);
532 Checksum cloneChecksumAfterModifyingOriginal;
533 clone->
AddChecksum(cloneChecksumAfterModifyingOriginal);
536 originalChecksum != originalChecksumAfterModifyingOriginal);
538 cloneChecksum == cloneChecksumAfterModifyingOriginal);
542 Checksum originalChecksumAfterModifyingClone;
543 dummy->
AddChecksum(originalChecksumAfterModifyingClone);
544 Checksum cloneChecksumAfterModifyingClone;
545 clone->
AddChecksum(cloneChecksumAfterModifyingClone);
548 "clone has been modified",
549 originalChecksumAfterModifyingClone ==
550 originalChecksumAfterModifyingOriginal);
553 cloneChecksumAfterModifyingClone ==
554 originalChecksumAfterModifyingOriginal);
557 static void Test_DummyComponent_SerializeDeserialize()
564 dummyChildA->
AddChild(dummyChildA1);
565 dummyChildA->
AddChild(dummyChildA2);
572 class DummyComponentWithCounter
576 DummyComponentWithCounter(ostream* os = NULL,
char c =
'X')
595 return new DummyComponentWithCounter();
601 m_counter += nrOfCycles;
604 for (
int i=0; i<nrOfCycles; ++i)
618 static void Test_DummyComponent_Execute_SingleStep()
658 static void Test_DummyComponent_Execute_MultiSingleStep()
671 const int nrOfStepsToRun = 23;
698 static void Test_DummyComponent_Execute_TwoComponentsSameSpeed()
750 static void Test_DummyComponent_Execute_TwoComponentsDifferentSpeed()
813 static void Test_DummyComponent_Execute_Continuous_SingleComponent()
844 static void Test_DummyComponent_Execute_Continuous_TwoComponentsSameSpeed()
881 stringstream correct;
882 for (
int i=0; i<n; ++i)
888 static void Test_DummyComponent_Execute_Continuous_TwoComponentsDifferentSpeed()
925 (a >= 122 + n/3) && (a <= 123 + n/3));
930 stringstream correct;
931 for (
int i=0; i<n; ++i) {
941 static void Test_DummyComponent_Execute_Continuous_ThreeComponentsDifferentSpeed()
972 (a >= n / 100 - 1) && (a <= n / 100 + 1));
979 (c >= n / 10 - 1) && (c <= n / 10 + 1));
985 stringstream singleStepStream;
1002 for (
int i=0; i<n; ++i) {
1007 UnitTest::Assert(
"output stream mismatch?", os.str() == singleStepStream.str());
1011 static void Test_DummyComponent_Execute_Continuous_ThreeComponentsDifferentSpeedWeird()
1044 stringstream singleStepStream;
1061 for (
int i=0; i<n; ++i) {
1066 UnitTest::Assert(
"output stream mismatch?", os.str() == singleStepStream.str());
1134 DummyComponentWithAllVariableTypes::Create,
1138 DummyComponentWithCounter::Create,
1142 UNITTEST(Test_DummyComponent_CreateComponent);
1145 UNITTEST(Test_DummyComponent_GetSetParent);
1148 UNITTEST(Test_DummyComponent_AddChild_Sets_Parent);
1149 UNITTEST(Test_DummyComponent_AddChildren_Count);
1150 UNITTEST(Test_DummyComponent_Add_Tree_Of_Children);
1151 UNITTEST(Test_DummyComponent_RemoveChild);
1152 UNITTEST(Test_DummyComponent_AddChild_UniqueName);
1155 UNITTEST(Test_DummyComponent_GeneratePath);
1156 UNITTEST(Test_DummyComponent_GenerateShortestPossiblePath);
1157 UNITTEST(Test_DummyComponent_LookupPath);
1158 UNITTEST(Test_DummyComponent_FindPathByPartialMatch);
1161 UNITTEST(Test_DummyComponent_GetUnknownVariable);
1164 UNITTEST(Test_DummyComponent_NonexistantMethodNotReexecutable);
1167 UNITTEST(Test_DummyComponent_Clone_Basic);
1168 UNITTEST(Test_DummyComponent_Clone_AllVariableTypes);
1171 UNITTEST(Test_DummyComponent_SerializeDeserialize);
1174 UNITTEST(Test_DummyComponent_Execute_SingleStep);
1175 UNITTEST(Test_DummyComponent_Execute_MultiSingleStep);
1176 UNITTEST(Test_DummyComponent_Execute_TwoComponentsSameSpeed);
1177 UNITTEST(Test_DummyComponent_Execute_TwoComponentsDifferentSpeed);
1178 UNITTEST(Test_DummyComponent_Execute_Continuous_SingleComponent);
1179 UNITTEST(Test_DummyComponent_Execute_Continuous_TwoComponentsSameSpeed);
1180 UNITTEST(Test_DummyComponent_Execute_Continuous_TwoComponentsDifferentSpeed);
1181 UNITTEST(Test_DummyComponent_Execute_Continuous_ThreeComponentsDifferentSpeed);
1182 UNITTEST(Test_DummyComponent_Execute_Continuous_ThreeComponentsDifferentSpeedWeird);