From 346ede8436acaf1e0fed78dcf9d1270dfbee13ec Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Tue, 28 Jun 2016 19:06:09 -0400 Subject: [PATCH] tmf: Add a few tests to TmfTraceUtilsSearchingTest Test the behavior of the search when there is no event match. Change-Id: I6c6bfb76acf73151851cab766f5d57026f7da7d8 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/76226 Reviewed-by: Matthew Khouzam Reviewed-by: Hudson CI --- .../trace/TmfTraceUtilsSearchingTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/TmfTraceUtilsSearchingTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/TmfTraceUtilsSearchingTest.java index b220989654..66e6d31f67 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/TmfTraceUtilsSearchingTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/TmfTraceUtilsSearchingTest.java @@ -80,6 +80,21 @@ public class TmfTraceUtilsSearchingTest { assertEquals(expectedEvent, actualEvent); } + /** + * Test the {@link TmfTraceUtils#getNextEventMatching} method where no event + * matches the passed predicate. It should return null. + */ + @Test + public void testNextMatchingEventNoMatch() { + ITmfTrace trace = fTrace; + assertNotNull(trace); + + Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("non-existent-event"); + + ITmfEvent actualEvent = TmfTraceUtils.getNextEventMatching(trace, START_RANK, predicate); + assertNull(actualEvent); + } + /** * Test the {@link TmfTraceUtils#getNextEventMatching} method, where the * event from which we start the search already matches the criterion (it @@ -115,6 +130,21 @@ public class TmfTraceUtilsSearchingTest { assertEquals(expectedEvent, actualEvent); } + /** + * Test the {@link TmfTraceUtils#getPreviousEventMatching} method where no event + * matches the passed predicate. It should return null. + */ + @Test + public void testPreviousMatchingEventNoMatch() { + ITmfTrace trace = fTrace; + assertNotNull(trace); + + Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("non-existent-event"); + + ITmfEvent actualEvent = TmfTraceUtils.getPreviousEventMatching(trace, START_RANK, predicate); + assertNull(actualEvent); + } + /** * Test the {@link TmfTraceUtils#getPreviousEventMatching} method, where the * event from which we start the search already matches the criterion (it -- 2.34.1