This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-net.git
The following commit(s) were added to refs/heads/master by this push: new 80638cd4 Use `assertThrows` in test new 2b56e229 Merge pull request #175 from basil/assertThrows 80638cd4 is described below commit 80638cd445be0e0aa7d78126756e25c57ebc6593 Author: Basil Crow <m...@basilcrow.com> AuthorDate: Wed Aug 23 07:51:58 2023 -0700 Use `assertThrows` in test --- src/test/java/org/apache/commons/net/SubnetUtilsTest.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/test/java/org/apache/commons/net/SubnetUtilsTest.java b/src/test/java/org/apache/commons/net/SubnetUtilsTest.java index 5decde14..85b0c60d 100644 --- a/src/test/java/org/apache/commons/net/SubnetUtilsTest.java +++ b/src/test/java/org/apache/commons/net/SubnetUtilsTest.java @@ -24,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; import org.apache.commons.net.util.SubnetUtils; import org.apache.commons.net.util.SubnetUtils.SubnetInfo; @@ -275,23 +274,13 @@ public class SubnetUtilsTest { info = utils.getInfo(); assertEquals("0.0.0.0", info.getNetmask()); assertEquals(4294967296L, info.getAddressCountLong()); - try { - info.getAddressCount(); - fail("Expected RuntimeException"); - } catch (final RuntimeException expected) { - // ignored - } + assertThrows(RuntimeException.class, info::getAddressCount); utils = new SubnetUtils("128.0.0.0/1"); utils.setInclusiveHostCount(true); info = utils.getInfo(); assertEquals("128.0.0.0", info.getNetmask()); assertEquals(2147483648L, info.getAddressCountLong()); - try { - info.getAddressCount(); - fail("Expected RuntimeException"); - } catch (final RuntimeException expected) { - // ignored - } + assertThrows(RuntimeException.class, info::getAddressCount); // if we exclude the broadcast and network addresses, the count is less than Integer.MAX_VALUE utils.setInclusiveHostCount(false); info = utils.getInfo();