Skip to content

Commit d714d41

Browse files
committed
enhance dom ut
1 parent e819b9f commit d714d41

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

src/domino/Domino.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
// . 1-go domino is like SW upgrade - 1-go then discard, next will use new domino
1919
// . n-go domino is like IM - repeat working till reboot
2020
// . after 024-03-19 domino supports n-go
21-
// - Q&A: (below; lots)
22-
//
23-
// - core: states_
21+
// . setState() only works on tiles without prev_ (chain head) - safe & simple
22+
// . tiles form DAG (directed acyclic graph), cycle links forbidden
2423
//
2524
// - VALUE:
2625
// * auto broadcast, auto callback, auto shape [MUST-HAVE!]
@@ -29,11 +28,14 @@
2928
// . template extension (PriDomino, etc)
3029
// . n-go domino
3130
//
31+
// - core: states_
32+
//
3233
// - MT safe: no
3334
// - use-safe: yes with conditions:
3435
// . no too many events/.. that use-up mem (impossible in most cases)
3536
// . user shall not loop ev-link (impossible unless deliberate)
3637
// . domino prevent is not 100%, see UT for details
38+
// - Q&A: (below; lots)
3739
// ***********************************************************************************************
3840
#pragma once
3941

ut/domino/DominoTest.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,23 @@ TYPED_TEST_P(DominoTest, bugFix_shallDeduceAll)
103103
EXPECT_TRUE(PARA_DOM->state("e2"));
104104
}
105105

106-
#define INVALID_PREV
106+
#define PREV
107107
// ***********************************************************************************************
108+
TYPED_TEST_P(DominoTest, GOLD_multi_allPrevSatisfied_thenPropagate)
109+
{
110+
// e3 depends on e1(T) AND e2(F)
111+
PARA_DOM->setPrev("e3", {{"e1", true}, {"e2", false}});
112+
EXPECT_FALSE(PARA_DOM->state("e3")) << "REQ: not all prev satisfied yet";
113+
114+
PARA_DOM->setState({{"e1", true}});
115+
EXPECT_TRUE(PARA_DOM->state("e3")) << "REQ: all prev satisfied => propagate T";
116+
117+
PARA_DOM->setState({{"e2", true}}); // now e2==true breaks link=false
118+
EXPECT_FALSE(PARA_DOM->state("e3")) << "REQ: one prev unsatisfied => propagate F";
119+
120+
PARA_DOM->setState({{"e1", false}}); // e1==false breaks link=true too
121+
EXPECT_FALSE(PARA_DOM->state("e3")) << "REQ: no prev satisfied => stay F";
122+
}
108123
TYPED_TEST_P(DominoTest, invalid_loopSelf)
109124
{
110125
EXPECT_EQ(Domino::D_EVENT_FAILED_RET, PARA_DOM->setPrev("e1", {{"e1", true }})) << "REQ: can't loop self";
@@ -126,7 +141,7 @@ TYPED_TEST_P(DominoTest, invalid_mixLoop)
126141
EXPECT_NE(Domino::D_EVENT_FAILED_RET, PARA_DOM->setPrev("e0", {{"e1", false}}));
127142
EXPECT_EQ(Domino::D_EVENT_FAILED_RET, PARA_DOM->setPrev("e1", {{"e0", true}})) << "REQ: can't T/F mix loop";
128143
}
129-
TYPED_TEST_P(DominoTest, invalidPrev_toBothTrueAndFalse)
144+
TYPED_TEST_P(DominoTest, whyFalse_diagnoseTrueFalseConflict)
130145
{
131146
// e11 <- (T) <- e10
132147
// \ /
@@ -293,11 +308,12 @@ REGISTER_TYPED_TEST_SUITE_P(DominoTest
293308
, setState_onlyAtChainHead
294309
, bugFix_shallDeduceAll
295310

311+
, GOLD_multi_allPrevSatisfied_thenPropagate
296312
, invalid_loopSelf
297313
, invalid_deepLoop
298314
, invalid_deeperLoop
299315
, invalid_mixLoop
300-
, invalidPrev_toBothTrueAndFalse
316+
, whyFalse_diagnoseTrueFalseConflict
301317

302318
, GOLD_multi_retOne
303319
, trueEvent_retEmpty

0 commit comments

Comments
 (0)