From 19ea45dca507d6f3fcae9b1803fd17ff6c3da597 Mon Sep 17 00:00:00 2001 From: Stefan Hahmann Date: Wed, 5 Jun 2024 12:10:21 +0200 Subject: [PATCH] Make it transparent in the docs that TreeUtils.getMaxTimepoint() return 0 in case of an empty model. * Update javadocs and unit test accordingly --- src/main/java/org/mastodon/util/TreeUtils.java | 4 +++- src/test/java/org/mastodon/util/TreeUtilsTest.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mastodon/util/TreeUtils.java b/src/main/java/org/mastodon/util/TreeUtils.java index 14149a5ac..f046320f6 100644 --- a/src/main/java/org/mastodon/util/TreeUtils.java +++ b/src/main/java/org/mastodon/util/TreeUtils.java @@ -249,7 +249,9 @@ public static int getMinTimepoint( final Model model ) } /** - * Gets the maximum timepoint in the given {@link Model} at which at least one {@link Spot} exists in the Model. + * Gets the maximum time point in the given {@link Model} at which at least one {@link Spot} exists in the Model. + *
+ * If the model is empty, returns 0. * @param model the {@link Model} * @return the timepoint */ diff --git a/src/test/java/org/mastodon/util/TreeUtilsTest.java b/src/test/java/org/mastodon/util/TreeUtilsTest.java index aefbdec85..b3784ae0e 100644 --- a/src/test/java/org/mastodon/util/TreeUtilsTest.java +++ b/src/test/java/org/mastodon/util/TreeUtilsTest.java @@ -191,6 +191,7 @@ public void testGetMaxTimepoint() { assertEquals( 3, TreeUtils.getMaxTimepoint( new ExampleGraph1().getModel() ) ); assertEquals( 7, TreeUtils.getMaxTimepoint( new ExampleGraph2().getModel() ) ); + assertEquals( 0, TreeUtils.getMaxTimepoint( new Model() ) ); } @Test