X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Ftests%2FComponentTest.java;h=ffd65503f2b2f06fa82c6f66a2747bc055a54ffb;hb=a37db10f5372ec09624b2ad9b60587e498991cbd;hp=831349d1c6ecef048abac1be1689837f981d7c3f;hpb=4c6114f75b39b77f328b7a095c2401389175e94e;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/tests/ComponentTest.java b/era.mi/src/era/mi/logic/tests/ComponentTest.java index 831349d1..ffd65503 100644 --- a/era.mi/src/era/mi/logic/tests/ComponentTest.java +++ b/era.mi/src/era/mi/logic/tests/ComponentTest.java @@ -1,5 +1,6 @@ package era.mi.logic.tests; +import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; @@ -284,6 +285,42 @@ class ComponentTest assertEquals(-1, a.getSignedValue()); } + boolean flag = false; + + @Test + void simpleTimelineTest() + { + Timeline t = new Timeline(3); + flag = false; + t.addEvent((e) -> + { + if (!flag) + fail(); + flag = false; + }, 15); + t.addEvent((e) -> + { + if (flag) + fail(); + flag = true; + }, 10); + t.addEvent((e) -> + { + if (flag) + fail(); + flag = true; + }, 20); + t.addEvent((e) -> + { + fail("Only supposed to execute until timestamp 20, not 25"); + }, 25); + + t.executeUntil(t.laterThan(20), 100); + + if (!flag) + fail(); + } + @Test void multipleInputs() {