Skip to content

Commit 8079049

Browse files
committed
enhance dom ut
1 parent 9851e27 commit 8079049

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ut/domino/DominoTest.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ TYPED_TEST_P(DominoTest, GOLD_setState_thenGetIt)
3838
EXPECT_EQ(0u, PARA_DOM->setState({{"e1", false}})) << "REQ: no state change";
3939
EXPECT_FALSE(PARA_DOM->state("e1")) << "REQ: no state change";
4040
}
41+
TYPED_TEST_P(DominoTest, invalidEv_retStateFalse)
42+
{
43+
EXPECT_FALSE(PARA_DOM->state(Domino::D_EVENT_FAILED_RET)) << "REQ: invalid event returns false";
44+
EXPECT_FALSE(PARA_DOM->state(99999)) << "REQ: out-of-range event returns false";
45+
}
4146

4247
#define BROADCAST_STATE
4348
// ***********************************************************************************************
@@ -102,6 +107,15 @@ TYPED_TEST_P(DominoTest, bugFix_shallDeduceAll)
102107
{"e0", false}});
103108
EXPECT_TRUE(PARA_DOM->state("e2"));
104109
}
110+
TYPED_TEST_P(DominoTest, GOLD_simuSetState)
111+
{
112+
PARA_DOM->setPrev("e2", {{"e1", true}});
113+
PARA_DOM->setPrev("e4", {{"e3", true}});
114+
115+
EXPECT_EQ(2u, PARA_DOM->setState({{"e1", true}, {"e3", true}}));
116+
EXPECT_TRUE(PARA_DOM->state("e2"));
117+
EXPECT_TRUE(PARA_DOM->state("e4"));
118+
}
105119

106120
#define PREV
107121
// ***********************************************************************************************
@@ -268,6 +282,11 @@ TYPED_TEST_P(DominoTest, search_partial_evName)
268282
// ***********************************************************************************************
269283
// req: both event & EvName are ID
270284
// ***********************************************************************************************
285+
TYPED_TEST_P(DominoTest, getEventBy_existing_event)
286+
{
287+
auto ev = PARA_DOM->newEvent("e1");
288+
EXPECT_EQ(ev, PARA_DOM->getEventBy("e1")) << "REQ: get existing event";
289+
}
271290
TYPED_TEST_P(DominoTest, nonConstInterface_shall_createUnExistEvent_withStateFalse)
272291
{
273292
// req: new ID by newEvent()
@@ -302,11 +321,13 @@ TYPED_TEST_P(DominoTest, noID_for_not_exist_EvName)
302321
// ***********************************************************************************************
303322
REGISTER_TYPED_TEST_SUITE_P(DominoTest
304323
, GOLD_setState_thenGetIt
324+
, invalidEv_retStateFalse
305325

306326
, GOLD_forward_broadcast_trueLink
307327
, GOLD_forward_broadcast_falseLink
308328
, setState_onlyAtChainHead
309329
, bugFix_shallDeduceAll
330+
, GOLD_simuSetState
310331

311332
, GOLD_multi_allPrevSatisfied_thenPropagate
312333
, invalid_loopSelf
@@ -323,6 +344,7 @@ REGISTER_TYPED_TEST_SUITE_P(DominoTest
323344

324345
, search_partial_evName
325346

347+
, getEventBy_existing_event
326348
, nonConstInterface_shall_createUnExistEvent_withStateFalse
327349
, noID_for_not_exist_EvName
328350
);

0 commit comments

Comments
 (0)