48 if (attributeName ==
"stable")
51 if (attributeName ==
"description")
52 return "A dummy component, which does nothing.";
65 static void Test_DummyComponent_CreateComponent()
71 component.
IsNULL() ==
false);
77 static void Test_DummyComponent_GetSetParent()
96 static void Test_DummyComponent_AddChild_Sets_Parent()
110 static void Test_DummyComponent_AddChildren_Count()
128 static void Test_DummyComponent_Add_Tree_Of_Children()
145 static void Test_DummyComponent_RemoveChild()
169 "there should still be 2 child components in dummyChildA",
175 static void Test_DummyComponent_AddChild_UniqueName()
223 static void Test_DummyComponent_GeneratePath()
248 static void Test_DummyComponent_GenerateShortestPossiblePath()
276 static void Test_DummyComponent_LookupPath()
284 component1.
IsNULL() ==
true);
288 component2 == dummyA);
300 component3 == dummyA);
304 component4.
IsNULL() ==
true);
308 component5 == child);
312 component6 == childchild);
315 static void Test_DummyComponent_FindPathByPartialMatch()
350 vector<string> matches;
364 matches[0],
"root.machine1.pcibus0");
366 matches[1],
"root.machine1.pcibus1");
368 matches[2],
"root.machine2.pcibus0");
374 matches[0],
"root.machine1");
380 matches[0],
"root.machine2.pcibus0");
387 static void Test_DummyComponent_GetUnknownVariable()
395 static void Test_DummyComponent_NonexistantMethodNotReexecutable()
404 static void Test_DummyComponent_Clone_Basic()
411 dummyChildA->
AddChild(dummyChildA1);
412 dummyChildA->
AddChild(dummyChildA2);
424 originalChecksum == cloneChecksum);
428 Checksum originalChecksumAfterModifyingOriginal;
429 dummy->
AddChecksum(originalChecksumAfterModifyingOriginal);
430 Checksum cloneChecksumAfterModifyingOriginal;
431 clone->
AddChecksum(cloneChecksumAfterModifyingOriginal);
434 originalChecksum != originalChecksumAfterModifyingOriginal);
436 cloneChecksum == cloneChecksumAfterModifyingOriginal);
440 Checksum originalChecksumAfterModifyingClone;
441 dummy->
AddChecksum(originalChecksumAfterModifyingClone);
442 Checksum cloneChecksumAfterModifyingClone;
443 clone->
AddChecksum(cloneChecksumAfterModifyingClone);
446 "clone has been modified",
447 originalChecksumAfterModifyingClone ==
448 originalChecksumAfterModifyingOriginal);
451 cloneChecksumAfterModifyingClone ==
452 originalChecksumAfterModifyingOriginal);
455 class DummyComponentWithAllVariableTypes
459 DummyComponentWithAllVariableTypes()
481 m_string =
"some value";
484 m_uint32 = 0x98f8aa01;
485 m_uint64 = ((uint64_t)0xf8192929 << 32) | 0x30300a0a;
494 return new DummyComponentWithAllVariableTypes();
509 static void Test_DummyComponent_Clone_AllVariableTypes()
529 originalChecksum == cloneChecksum);
533 Checksum originalChecksumAfterModifyingOriginal;
534 dummy->
AddChecksum(originalChecksumAfterModifyingOriginal);
535 Checksum cloneChecksumAfterModifyingOriginal;
536 clone->
AddChecksum(cloneChecksumAfterModifyingOriginal);
539 originalChecksum != originalChecksumAfterModifyingOriginal);
541 cloneChecksum == cloneChecksumAfterModifyingOriginal);
545 Checksum originalChecksumAfterModifyingClone;
546 dummy->
AddChecksum(originalChecksumAfterModifyingClone);
547 Checksum cloneChecksumAfterModifyingClone;
548 clone->
AddChecksum(cloneChecksumAfterModifyingClone);
551 "clone has been modified",
552 originalChecksumAfterModifyingClone ==
553 originalChecksumAfterModifyingOriginal);
556 cloneChecksumAfterModifyingClone ==
557 originalChecksumAfterModifyingOriginal);
560 static void Test_DummyComponent_SerializeDeserialize()
567 dummyChildA->
AddChild(dummyChildA1);
568 dummyChildA->
AddChild(dummyChildA2);
575 class DummyComponentWithCounter
579 DummyComponentWithCounter(ostream* os = NULL,
char c =
'X')
598 return new DummyComponentWithCounter();
604 m_counter += nrOfCycles;
607 for (
int i=0; i<nrOfCycles; ++i)
621 static void Test_DummyComponent_Execute_SingleStep()
661 static void Test_DummyComponent_Execute_MultiSingleStep()
674 const int nrOfStepsToRun = 23;
701 static void Test_DummyComponent_Execute_TwoComponentsSameSpeed()
753 static void Test_DummyComponent_Execute_TwoComponentsDifferentSpeed()
816 static void Test_DummyComponent_Execute_Continuous_SingleComponent()
847 static void Test_DummyComponent_Execute_Continuous_TwoComponentsSameSpeed()
884 stringstream correct;
885 for (
int i=0; i<n; ++i)
891 static void Test_DummyComponent_Execute_Continuous_TwoComponentsDifferentSpeed()
928 (a >= 122 + n/3) && (a <= 123 + n/3));
933 stringstream correct;
934 for (
int i=0; i<n; ++i) {
944 static void Test_DummyComponent_Execute_Continuous_ThreeComponentsDifferentSpeed()
975 (a >= n / 100 - 1) && (a <= n / 100 + 1));
982 (c >= n / 10 - 1) && (c <= n / 10 + 1));
988 stringstream singleStepStream;
1005 for (
int i=0; i<n; ++i) {
1010 UnitTest::Assert(
"output stream mismatch?", os.str() == singleStepStream.str());
1014 static void Test_DummyComponent_Execute_Continuous_ThreeComponentsDifferentSpeedWeird()
1047 stringstream singleStepStream;
1064 for (
int i=0; i<n; ++i) {
1069 UnitTest::Assert(
"output stream mismatch?", os.str() == singleStepStream.str());
1137 DummyComponentWithAllVariableTypes::Create,
1141 DummyComponentWithCounter::Create,
1145 UNITTEST(Test_DummyComponent_CreateComponent);
1148 UNITTEST(Test_DummyComponent_GetSetParent);
1151 UNITTEST(Test_DummyComponent_AddChild_Sets_Parent);
1152 UNITTEST(Test_DummyComponent_AddChildren_Count);
1153 UNITTEST(Test_DummyComponent_Add_Tree_Of_Children);
1154 UNITTEST(Test_DummyComponent_RemoveChild);
1155 UNITTEST(Test_DummyComponent_AddChild_UniqueName);
1158 UNITTEST(Test_DummyComponent_GeneratePath);
1159 UNITTEST(Test_DummyComponent_GenerateShortestPossiblePath);
1160 UNITTEST(Test_DummyComponent_LookupPath);
1161 UNITTEST(Test_DummyComponent_FindPathByPartialMatch);
1164 UNITTEST(Test_DummyComponent_GetUnknownVariable);
1167 UNITTEST(Test_DummyComponent_NonexistantMethodNotReexecutable);
1170 UNITTEST(Test_DummyComponent_Clone_Basic);
1171 UNITTEST(Test_DummyComponent_Clone_AllVariableTypes);
1174 UNITTEST(Test_DummyComponent_SerializeDeserialize);
1177 UNITTEST(Test_DummyComponent_Execute_SingleStep);
1178 UNITTEST(Test_DummyComponent_Execute_MultiSingleStep);
1179 UNITTEST(Test_DummyComponent_Execute_TwoComponentsSameSpeed);
1180 UNITTEST(Test_DummyComponent_Execute_TwoComponentsDifferentSpeed);
1181 UNITTEST(Test_DummyComponent_Execute_Continuous_SingleComponent);
1182 UNITTEST(Test_DummyComponent_Execute_Continuous_TwoComponentsSameSpeed);
1183 UNITTEST(Test_DummyComponent_Execute_Continuous_TwoComponentsDifferentSpeed);
1184 UNITTEST(Test_DummyComponent_Execute_Continuous_ThreeComponentsDifferentSpeed);
1185 UNITTEST(Test_DummyComponent_Execute_Continuous_ThreeComponentsDifferentSpeedWeird);