X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Ftests%2FComponentTest.java;h=0e2b3460f30da8021673aa24ff3c5b5ddb36c57c;hb=0ce7f7122a702c3d6a4b864172b8c93620c8b03b;hp=c52833c031c32e326f7921b65d2ff7c25a0171f8;hpb=6ab8014cf6bb882187ab4d22fdf460dc0adbc2ab;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 c52833c0..0e2b3460 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() {