]> git.mxchange.org Git - jcore-utils.git/commitdiff
Contined:
authorRoland Häder <roland@mxchange.org>
Thu, 6 Oct 2022 18:09:22 +0000 (20:09 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 6 Oct 2022 18:09:22 +0000 (20:09 +0200)
- added tests for Comparables.checkAll()

test/org/mxchange/jcoreutils/test/comparable/ComparablesTest.java [new file with mode: 0644]

diff --git a/test/org/mxchange/jcoreutils/test/comparable/ComparablesTest.java b/test/org/mxchange/jcoreutils/test/comparable/ComparablesTest.java
new file mode 100644 (file)
index 0000000..2c734dd
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2022 Roland Häder<roland@mxchange.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcoreutils.test.comparable;
+
+import org.mxchange.jcoreutils.comparable.Comparables;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Test cases for Comparables utlities class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class ComparablesTest {
+
+       /**
+        * Default constructor
+        */
+       public ComparablesTest () {
+       }
+
+       @Test (description = "Tests if 1 is returned")
+       public void testAboveZero () {
+               // Test method
+               Assert.assertEquals(Comparables.checkAll(new int[]{0, 0, 1}), 1);
+               Assert.assertEquals(Comparables.checkAll(new int[]{0, 0, 10}), 1);
+               Assert.assertEquals(Comparables.checkAll(new int[]{0, 0, 100}), 1);
+       }
+
+       @Test (description = "Tests if -1 is returned")
+       public void testBelowZero () {
+               // Test method
+               Assert.assertEquals(Comparables.checkAll(new int[]{0, 0, -1}), -1);
+               Assert.assertEquals(Comparables.checkAll(new int[]{0, 0, -10}), -1);
+               Assert.assertEquals(Comparables.checkAll(new int[]{0, 0, -100}), -1);
+       }
+
+       @Test (description = "Tests if when provided array is empty a specific exception is thrown", expectedExceptions = {IllegalArgumentException.class})
+       public void testIllegalArgumentException () {
+               // Test method
+               Comparables.checkAll(new int[]{});
+       }
+
+       @Test (description = "Tests if zero is returned")
+       public void testZero () {
+               // Test method
+               Assert.assertEquals(Comparables.checkAll(new int[]{0, 0, 0}), 0);
+       }
+
+}