Skip to content

Commit adaf3b1

Browse files
committed
enhance dom ut
1 parent 8079049 commit adaf3b1

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

ut/domino/DominoTest.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ TYPED_TEST_P(DominoTest, GOLD_multi_allPrevSatisfied_thenPropagate)
133133

134134
PARA_DOM->setState({{"e1", false}}); // e1==false breaks link=true too
135135
EXPECT_FALSE(PARA_DOM->state("e3")) << "REQ: no prev satisfied => stay F";
136+
// REQ: cumulative setPrev - add more prev to e3
137+
PARA_DOM->setPrev("e3", {{"e4", true}}); // add second prev e4(T)
138+
EXPECT_FALSE(PARA_DOM->state("e3")) << "REQ: both old & new prev unsatisfied";
139+
PARA_DOM->setState({{"e1", true}}); // restore e1=T
140+
EXPECT_FALSE(PARA_DOM->state("e3")) << "REQ: still need e2 & e4 both T";
141+
PARA_DOM->setState({{"e2", false}, {"e4", true}}); // restore e2=F, set e4=T
142+
EXPECT_TRUE(PARA_DOM->state("e3")) << "REQ: all prev satisfied => propagate T";
136143
}
137144
TYPED_TEST_P(DominoTest, invalid_loopSelf)
138145
{
@@ -255,7 +262,7 @@ TYPED_TEST_P(DominoTest, incCov_whyFalse_whyTrue)
255262
EXPECT_EQ("e11==true", PARA_DOM->whyFalse(e10)) << "REQ: inc branch coverage";
256263
}
257264

258-
#define SEARCH_PARTIAL_EVNAME
265+
#define SEARCH_EVNAME
259266
// ***********************************************************************************************
260267
TYPED_TEST_P(DominoTest, search_partial_evName)
261268
{
@@ -277,6 +284,27 @@ TYPED_TEST_P(DominoTest, search_partial_evName)
277284
}
278285
EXPECT_EQ(0u, nFound) << "REQ: not found";
279286
}
287+
TYPED_TEST_P(DominoTest, search_all_evNames)
288+
{
289+
// REQ: evNames() must contain all created events - completeness verification
290+
PARA_DOM->newEvent("e1");
291+
PARA_DOM->newEvent("e2");
292+
PARA_DOM->newEvent("e3");
293+
294+
auto&& evNames = PARA_DOM->evNames();
295+
EXPECT_EQ(3u, evNames.size()) << "REQ: evNames should contain all 3 created events";
296+
297+
// Verify each created event is in the returned container
298+
bool found_e1 = false, found_e2 = false, found_e3 = false;
299+
for (auto&& evPair : evNames) {
300+
if (evPair.second == "e1") found_e1 = true;
301+
if (evPair.second == "e2") found_e2 = true;
302+
if (evPair.second == "e3") found_e3 = true;
303+
}
304+
EXPECT_TRUE(found_e1) << "REQ: e1 must be in evNames()";
305+
EXPECT_TRUE(found_e2) << "REQ: e2 must be in evNames()";
306+
EXPECT_TRUE(found_e3) << "REQ: e3 must be in evNames()";
307+
}
280308

281309
#define ID
282310
// ***********************************************************************************************
@@ -310,8 +338,14 @@ TYPED_TEST_P(DominoTest, nonConstInterface_shall_createUnExistEvent_withStateFal
310338
this->uniqueEVs_.insert(PARA_DOM->getEventBy("e4"));
311339
EXPECT_EQ(4u, this->uniqueEVs_.size());
312340

341+
// REQ: newEvent() with explicit name is idempotent (Event:EvName=1:1)
342+
auto ev1 = PARA_DOM->newEvent("myEvent");
343+
auto ev2 = PARA_DOM->newEvent("myEvent");
344+
EXPECT_EQ(ev1, ev2) << "REQ: repeated newEvent() with same name returns same Event";
345+
346+
this->uniqueEVs_.insert(ev1); // add myEvent to set
313347
this->uniqueEVs_.insert(Domino::D_EVENT_FAILED_RET); // REQ: new ID != Domino::D_EVENT_FAILED_RET
314-
EXPECT_EQ(5u, this->uniqueEVs_.size());
348+
EXPECT_EQ(6u, this->uniqueEVs_.size());
315349
}
316350
TYPED_TEST_P(DominoTest, noID_for_not_exist_EvName)
317351
{
@@ -343,6 +377,7 @@ REGISTER_TYPED_TEST_SUITE_P(DominoTest
343377
, incCov_whyFalse_whyTrue
344378

345379
, search_partial_evName
380+
, search_all_evNames
346381

347382
, getEventBy_existing_event
348383
, nonConstInterface_shall_createUnExistEvent_withStateFalse

0 commit comments

Comments
 (0)