You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/12/17 00:05:34 UTC
[commons-numbers] branch master updated: Changed tests to use
assertThrows.
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
The following commit(s) were added to refs/heads/master by this push:
new cf5ec33 Changed tests to use assertThrows.
cf5ec33 is described below
commit cf5ec339a80ccc6ede2b81d623a94d8dd7f9c25d
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Tue Dec 17 00:03:12 2019 +0000
Changed tests to use assertThrows.
---
.../arrays/MultidimensionalCounterTest.java | 60 ++++------------------
1 file changed, 9 insertions(+), 51 deletions(-)
diff --git a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/MultidimensionalCounterTest.java b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/MultidimensionalCounterTest.java
index c9730fc..7294251 100644
--- a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/MultidimensionalCounterTest.java
+++ b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/MultidimensionalCounterTest.java
@@ -28,58 +28,16 @@ import org.junit.jupiter.api.Test;
public class MultidimensionalCounterTest {
@Test
public void testPreconditions() {
- MultidimensionalCounter c;
+ Assertions.assertThrows(IllegalArgumentException.class, () -> MultidimensionalCounter.of(0, 1));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> MultidimensionalCounter.of(2, 0));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> MultidimensionalCounter.of(-1, 1));
- try {
- c = MultidimensionalCounter.of(0, 1);
- Assertions.fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // Expected.
- }
- try {
- c = MultidimensionalCounter.of(2, 0);
- Assertions.fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // Expected.
- }
- try {
- c = MultidimensionalCounter.of(-1, 1);
- Assertions.fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // Expected.
- }
-
- c = MultidimensionalCounter.of(2, 3);
- try {
- c.toUni(1, 1, 1);
- Assertions.fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException e) {
- // Expected.
- }
- try {
- c.toUni(3, 1);
- Assertions.fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {
- // Expected.
- }
- try {
- c.toUni(0, -1);
- Assertions.fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {
- // Expected.
- }
- try {
- c.toMulti(-1);
- Assertions.fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {
- // Expected.
- }
- try {
- c.toMulti(6);
- Assertions.fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {
- // Expected.
- }
+ final MultidimensionalCounter c = MultidimensionalCounter.of(2, 3);
+ Assertions.assertThrows(IllegalArgumentException.class, () -> c.toUni(1, 1, 1));
+ Assertions.assertThrows(IndexOutOfBoundsException.class, () -> c.toUni(3, 1));
+ Assertions.assertThrows(IndexOutOfBoundsException.class, () -> c.toUni(0, -1));
+ Assertions.assertThrows(IndexOutOfBoundsException.class, () -> c.toMulti(-1));
+ Assertions.assertThrows(IndexOutOfBoundsException.class, () -> c.toMulti(6));
}
@Test