--- /dev/null
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+<suite name="jcore-utils">
+ <!--
+ see examples at http://testng.org/doc/documentation-main.html#testng-xml
+
+ <suite-files>
+ <suite-file path="./junit-suite.xml" />
+ </suite-files>
+
+ <test name="TimeOut">
+ <classes>
+ <class name="test.timeout.TimeOutTest" />
+ <class name="test.timeout.TimeOutFromXmlTest"/>
+ <class name="test.timeout.TimeOutThreadLocalSampleTest"/>
+ </classes>
+ </test>
+ -->
+ <test name="org.mxchange.jcoreutils.test suite">
+ <packages>
+ <package name="org.mxchange.jcoreutils"/>
+ </packages>
+ </test>
+</suite>
--- /dev/null
+/*
+ * 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.comparable;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Test cases for ComparableUtils utilities class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class ComparableUtilsTest {
+
+ /**
+ * Default constructor
+ */
+ public ComparableUtilsTest () {
+ }
+
+ @Test (description = "Tests if 1 is returned")
+ public void testAboveZero () {
+ // Test method
+ Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, 1}), 1);
+ Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, 10}), 1);
+ Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, 100}), 1);
+ }
+
+ @Test (description = "Tests if -1 is returned")
+ public void testBelowZero () {
+ // Test method
+ Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, -1}), -1);
+ Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, -10}), -1);
+ Assert.assertEquals(ComparableUtils.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
+ ComparableUtils.checkAll(new int[]{});
+ }
+
+ @Test (description = "Tests if zero is returned")
+ public void testZero () {
+ // Test method
+ Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, 0}), 0);
+ }
+
+}
--- /dev/null
+/*
+ * 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.dates;
+
+import java.util.Calendar;
+import java.util.Date;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Test cases for DateUtils utilities class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class DateUtilsTest {
+
+ /**
+ * Default constructor
+ */
+ public DateUtilsTest () {
+ }
+
+ @Test (description = "Compares two different java.util.Date instances")
+ public void testCompareDifferentDates () {
+ // Init date instance
+ final Date date1 = new Date();
+
+ // Get calendar and add a month
+ final Calendar calendar = Calendar.getInstance();
+ calendar.setTime(new Date());
+ calendar.add(Calendar.MONTH, 1);
+
+ // Should always be 1
+ Assert.assertEquals(DateUtils.compareYearMonthDay(date1, calendar.getTime()), 1);
+ }
+
+ @Test (description = "Compares left null with a java.util.Date instance")
+ public void testCompareLeftNullDate () {
+ // Init instance
+ final Date date = new Date();
+
+ // Should always be zero
+ Assert.assertEquals(DateUtils.compareYearMonthDay(null, date), -1);
+ }
+
+ @Test (description = "Compares right null with a java.util.Date instance")
+ public void testCompareRightNullDate () {
+ // Init instance
+ final Date date = new Date();
+
+ // Should always be 1
+ Assert.assertEquals(DateUtils.compareYearMonthDay(date, null), 1);
+ }
+
+ @Test (description = "Compares the same java.util.Date instances")
+ public void testCompareSameInstances () {
+ // Init instance
+ final Date date = new Date();
+
+ // Should always be -1
+ Assert.assertEquals(DateUtils.compareYearMonthDay(date, date), 0);
+ }
+
+}
--- /dev/null
+/*
+ * 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.number;
+
+import java.math.BigDecimal;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Tests methods in SafeNumberUtils class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class SafeNumberUtilsTest {
+
+ private static final short SHORT1 = 1;
+
+ private static final short SHORT2 = 2;
+
+ private static final short SHORT3 = 3;
+
+ private static final short SHORT4 = 4;
+
+ /**
+ * Default constructor
+ */
+ public SafeNumberUtilsTest () {
+ }
+
+ @DataProvider (name = "bigdecimal-larger-numbers-provider")
+ public Object[][] createLargerBigDecimal () {
+ return new Object[][]{
+ {new BigDecimal(1), new BigDecimal(2)},
+ {new BigDecimal(2), new BigDecimal(3)},
+ {new BigDecimal(3), new BigDecimal(4)}
+ };
+ }
+
+ @DataProvider (name = "int-larger-numbers-provider")
+ public Object[][] createLargerInteger () {
+ return new Object[][]{
+ {1, 2},
+ {2, 3},
+ {3, 4}
+ };
+ }
+
+ @DataProvider (name = "long-larger-numbers-provider")
+ public Object[][] createLargerLong () {
+ return new Object[][]{
+ {1L, 2L},
+ {2L, 3L},
+ {3L, 4L}
+ };
+ }
+
+ @DataProvider (name = "short-larger-numbers-provider")
+ public Object[][] createLargerShort () {
+ return new Object[][]{
+ {SHORT1, SHORT2},
+ {SHORT2, SHORT3},
+ {SHORT3, SHORT4}
+ };
+ }
+
+ @DataProvider (name = "bigdecimal-left-null-numbers-provider")
+ public Object[][] createLeftNullBigDecimal () {
+ return new Object[][]{
+ {null, new BigDecimal(1)},
+ {null, new BigDecimal(2)},
+ {null, new BigDecimal(3)}
+ };
+ }
+
+ @DataProvider (name = "int-left-null-numbers-provider")
+ public Object[][] createLeftNullInteger () {
+ return new Object[][]{
+ {null, 1},
+ {null, 2},
+ {null, 3}
+ };
+ }
+
+ @DataProvider (name = "long-left-null-numbers-provider")
+ public Object[][] createLeftNullLong () {
+ return new Object[][]{
+ {null, 1L},
+ {null, 2L},
+ {null, 3L}
+ };
+ }
+
+ @DataProvider (name = "short-left-null-numbers-provider")
+ public Object[][] createLeftNullShort () {
+ return new Object[][]{
+ {null, SHORT1},
+ {null, SHORT2},
+ {null, SHORT3}
+ };
+ }
+
+ @DataProvider (name = "bigdecimal-right-null-numbers-provider")
+ public Object[][] createRightNullBigDecimal () {
+ return new Object[][]{
+ {new BigDecimal(2), null},
+ {new BigDecimal(3), null},
+ {new BigDecimal(4), null}
+ };
+ }
+
+ @DataProvider (name = "int-right-null-numbers-provider")
+ public Object[][] createRightNullInteger () {
+ return new Object[][]{
+ {1, null},
+ {2, null},
+ {3, null}
+ };
+ }
+
+ @DataProvider (name = "long-right-null-numbers-provider")
+ public Object[][] createRightNullLong () {
+ return new Object[][]{
+ {1L, null},
+ {2L, null},
+ {3L, null}
+ };
+ }
+
+ @DataProvider (name = "short-right-null-numbers-provider")
+ public Object[][] createRightNullShort () {
+ return new Object[][]{
+ {SHORT1, null},
+ {SHORT2, null},
+ {SHORT3, null}
+ };
+ }
+
+ @DataProvider (name = "bigdecimal-same-numbers-provider")
+ public Object[][] createSameBigDecimal () {
+ return new Object[][]{
+ {new BigDecimal(1), new BigDecimal(1)},
+ {new BigDecimal(2), new BigDecimal(2)},
+ {new BigDecimal(3), new BigDecimal(3)}
+ };
+ }
+
+ @DataProvider (name = "int-same-numbers-provider")
+ public Object[][] createSameInteger () {
+ return new Object[][]{
+ {1, 1},
+ {2, 2},
+ {3, 3}
+ };
+ }
+
+ @DataProvider (name = "long-same-numbers-provider")
+ public Object[][] createSameLong () {
+ return new Object[][]{
+ {1L, 1L},
+ {2L, 2L},
+ {3L, 3L}
+ };
+ }
+
+ @DataProvider (name = "short-same-numbers-provider")
+ public Object[][] createSameShort () {
+ return new Object[][]{
+ {SHORT1, SHORT1},
+ {SHORT2, SHORT2},
+ {SHORT3, SHORT3}
+ };
+ }
+
+ @DataProvider (name = "bigdecimal-smaller-numbers-provider")
+ public Object[][] createSmallerBigDecimal () {
+ return new Object[][]{
+ {new BigDecimal(2), new BigDecimal(1)},
+ {new BigDecimal(3), new BigDecimal(2)},
+ {new BigDecimal(4), new BigDecimal(3)}
+ };
+ }
+
+ @DataProvider (name = "int-smaller-numbers-provider")
+ public Object[][] createSmallerInteger () {
+ return new Object[][]{
+ {2, 1},
+ {3, 2},
+ {4, 3}
+ };
+ }
+
+ @DataProvider (name = "long-smaller-numbers-provider")
+ public Object[][] createSmallerLong () {
+ return new Object[][]{
+ {2L, 1L},
+ {3L, 2L},
+ {4L, 3L}
+ };
+ }
+
+ @DataProvider (name = "short-smaller-numbers-provider")
+ public Object[][] createSmallerShort () {
+ return new Object[][]{
+ {SHORT2, SHORT1},
+ {SHORT3, SHORT2},
+ {SHORT4, SHORT3}
+ };
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with larger", dataProvider = "int-larger-numbers-provider")
+ public void testCompareLarger (final Integer var1, final Integer var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with larger", dataProvider = "long-larger-numbers-provider")
+ public void testCompareLarger (final Long var1, final Long var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with larger numbers", dataProvider = "short-larger-numbers-provider")
+ public void testCompareLarger (final Short var1, final Short var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with larger numbers", dataProvider = "bigdecimal-larger-numbers-provider")
+ public void testCompareLarger (final BigDecimal var1, final BigDecimal var2) {
+ // All compare() should always return 1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with left null numbers", dataProvider = "int-left-null-numbers-provider")
+ public void testCompareLeftNull (final Integer var1, final Integer var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with left null numbers", dataProvider = "long-left-null-numbers-provider")
+ public void testCompareLeftNull (final Long var1, final Long var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with left null numbers", dataProvider = "short-left-null-numbers-provider")
+ public void testCompareLeftNull (final Short var1, final Short var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with left null numbers", dataProvider = "bigdecimal-left-null-numbers-provider")
+ public void testCompareLeftNull (final BigDecimal var1, final BigDecimal var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with right null numbers", dataProvider = "int-right-null-numbers-provider")
+ public void testCompareRightNull (final Integer var1, final Integer var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with right null numbers", dataProvider = "long-right-null-numbers-provider")
+ public void testCompareRightNull (final Long var1, final Long var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with right null numbers", dataProvider = "short-right-null-numbers-provider")
+ public void testCompareRightNull (final Short var1, final Short var2) {
+ // All compare() should always return 1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with right null numbers", dataProvider = "bigdecimal-right-null-numbers-provider")
+ public void testCompareRightNull (final BigDecimal var1, final BigDecimal var2) {
+ // All compare() should always return 1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with same numbers", dataProvider = "int-same-numbers-provider")
+ public void testCompareSame (final Integer var1, final Integer var2) {
+ // All compare() should always return 0
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 0);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with same numbers", dataProvider = "long-same-numbers-provider")
+ public void testCompareSame (final Long var1, final Long var2) {
+ // All compare() should always return 0
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 0);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with same numbers", dataProvider = "short-same-numbers-provider")
+ public void testCompareSame (final Short var1, final Short var2) {
+ // All compare() should always return -1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 0);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with same numbers", dataProvider = "bigdecimal-same-numbers-provider")
+ public void testCompareSame (final BigDecimal var1, final BigDecimal var2) {
+ // All compare() should always return 0
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 0);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with smaller numbers", dataProvider = "int-smaller-numbers-provider")
+ public void testCompareSmaller (final Integer var1, final Integer var2) {
+ // All compare() should always return 1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with smaller numbers", dataProvider = "long-smaller-numbers-provider")
+ public void testCompareSmaller (final Long var1, final Long var2) {
+ // All compare() should always return 1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with smaller numbers", dataProvider = "short-smaller-numbers-provider")
+ public void testCompareSmaller (final Short var1, final Short var2) {
+ // All compare() should always return 1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
+ }
+
+ @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with smaller numbers", dataProvider = "bigdecimal-smaller-numbers-provider")
+ public void testCompareSmaller (final BigDecimal var1, final BigDecimal var2) {
+ // All compare() should always return 1
+ Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
+ }
+
+}
+++ /dev/null
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
-<suite name="jcore-utils">
- <!--
- see examples at http://testng.org/doc/documentation-main.html#testng-xml
-
- <suite-files>
- <suite-file path="./junit-suite.xml" />
- </suite-files>
-
- <test name="TimeOut">
- <classes>
- <class name="test.timeout.TimeOutTest" />
- <class name="test.timeout.TimeOutFromXmlTest"/>
- <class name="test.timeout.TimeOutThreadLocalSampleTest"/>
- </classes>
- </test>
- -->
- <test name="org.mxchange.jcoreutils.test suite">
- <packages>
- <package name="org.mxchange.jcoreutils.test"/>
- </packages>
- </test>
-</suite>
+++ /dev/null
-/*
- * 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.ComparableUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Test cases for ComparableUtils utilities class
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class ComparableUtilsTest {
-
- /**
- * Default constructor
- */
- public ComparableUtilsTest () {
- }
-
- @Test (description = "Tests if 1 is returned")
- public void testAboveZero () {
- // Test method
- Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, 1}), 1);
- Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, 10}), 1);
- Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, 100}), 1);
- }
-
- @Test (description = "Tests if -1 is returned")
- public void testBelowZero () {
- // Test method
- Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, -1}), -1);
- Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, -10}), -1);
- Assert.assertEquals(ComparableUtils.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
- ComparableUtils.checkAll(new int[]{});
- }
-
- @Test (description = "Tests if zero is returned")
- public void testZero () {
- // Test method
- Assert.assertEquals(ComparableUtils.checkAll(new int[]{0, 0, 0}), 0);
- }
-
-}
+++ /dev/null
-/*
- * 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.dates;
-
-import java.util.Calendar;
-import java.util.Date;
-import org.mxchange.jcoreutils.dates.DateUtils;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Test cases for DateUtils utilities class
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class DateUtilsTest {
-
- /**
- * Default constructor
- */
- public DateUtilsTest () {
- }
-
- @Test (description = "Compares two different java.util.Date instances")
- public void testCompareDifferentDates () {
- // Init date instance
- final Date date1 = new Date();
-
- // Get calendar and add a month
- final Calendar calendar = Calendar.getInstance();
- calendar.setTime(new Date());
- calendar.add(Calendar.MONTH, 1);
-
- // Should always be 1
- Assert.assertEquals(DateUtils.compareYearMonthDay(date1, calendar.getTime()), 1);
- }
-
- @Test (description = "Compares left null with a java.util.Date instance")
- public void testCompareLeftNullDate () {
- // Init instance
- final Date date = new Date();
-
- // Should always be zero
- Assert.assertEquals(DateUtils.compareYearMonthDay(null, date), -1);
- }
-
- @Test (description = "Compares right null with a java.util.Date instance")
- public void testCompareRightNullDate () {
- // Init instance
- final Date date = new Date();
-
- // Should always be 1
- Assert.assertEquals(DateUtils.compareYearMonthDay(date, null), 1);
- }
-
- @Test (description = "Compares the same java.util.Date instances")
- public void testCompareSameInstances () {
- // Init instance
- final Date date = new Date();
-
- // Should always be -1
- Assert.assertEquals(DateUtils.compareYearMonthDay(date, date), 0);
- }
-
-}
+++ /dev/null
-/*
- * 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.number;
-
-import java.math.BigDecimal;
-import org.mxchange.jcoreutils.number.SafeNumberUtils;
-import org.testng.Assert;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- * Tests methods in SafeNumberUtils class
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class SafeNumberUtilsTest {
-
- private static final short SHORT1 = 1;
-
- private static final short SHORT2 = 2;
-
- private static final short SHORT3 = 3;
-
- private static final short SHORT4 = 4;
-
- /**
- * Default constructor
- */
- public SafeNumberUtilsTest () {
- }
-
- @DataProvider (name = "bigdecimal-larger-numbers-provider")
- public Object[][] createLargerBigDecimal () {
- return new Object[][]{
- {new BigDecimal(1), new BigDecimal(2)},
- {new BigDecimal(2), new BigDecimal(3)},
- {new BigDecimal(3), new BigDecimal(4)}
- };
- }
-
- @DataProvider (name = "int-larger-numbers-provider")
- public Object[][] createLargerInteger () {
- return new Object[][]{
- {1, 2},
- {2, 3},
- {3, 4}
- };
- }
-
- @DataProvider (name = "long-larger-numbers-provider")
- public Object[][] createLargerLong () {
- return new Object[][]{
- {1L, 2L},
- {2L, 3L},
- {3L, 4L}
- };
- }
-
- @DataProvider (name = "short-larger-numbers-provider")
- public Object[][] createLargerShort () {
- return new Object[][]{
- {SHORT1, SHORT2},
- {SHORT2, SHORT3},
- {SHORT3, SHORT4}
- };
- }
-
- @DataProvider (name = "bigdecimal-left-null-numbers-provider")
- public Object[][] createLeftNullBigDecimal () {
- return new Object[][]{
- {null, new BigDecimal(1)},
- {null, new BigDecimal(2)},
- {null, new BigDecimal(3)}
- };
- }
-
- @DataProvider (name = "int-left-null-numbers-provider")
- public Object[][] createLeftNullInteger () {
- return new Object[][]{
- {null, 1},
- {null, 2},
- {null, 3}
- };
- }
-
- @DataProvider (name = "long-left-null-numbers-provider")
- public Object[][] createLeftNullLong () {
- return new Object[][]{
- {null, 1L},
- {null, 2L},
- {null, 3L}
- };
- }
-
- @DataProvider (name = "short-left-null-numbers-provider")
- public Object[][] createLeftNullShort () {
- return new Object[][]{
- {null, SHORT1},
- {null, SHORT2},
- {null, SHORT3}
- };
- }
-
- @DataProvider (name = "bigdecimal-right-null-numbers-provider")
- public Object[][] createRightNullBigDecimal () {
- return new Object[][]{
- {new BigDecimal(2), null},
- {new BigDecimal(3), null},
- {new BigDecimal(4), null}
- };
- }
-
- @DataProvider (name = "int-right-null-numbers-provider")
- public Object[][] createRightNullInteger () {
- return new Object[][]{
- {1, null},
- {2, null},
- {3, null}
- };
- }
-
- @DataProvider (name = "long-right-null-numbers-provider")
- public Object[][] createRightNullLong () {
- return new Object[][]{
- {1L, null},
- {2L, null},
- {3L, null}
- };
- }
-
- @DataProvider (name = "short-right-null-numbers-provider")
- public Object[][] createRightNullShort () {
- return new Object[][]{
- {SHORT1, null},
- {SHORT2, null},
- {SHORT3, null}
- };
- }
-
- @DataProvider (name = "bigdecimal-same-numbers-provider")
- public Object[][] createSameBigDecimal () {
- return new Object[][]{
- {new BigDecimal(1), new BigDecimal(1)},
- {new BigDecimal(2), new BigDecimal(2)},
- {new BigDecimal(3), new BigDecimal(3)}
- };
- }
-
- @DataProvider (name = "int-same-numbers-provider")
- public Object[][] createSameInteger () {
- return new Object[][]{
- {1, 1},
- {2, 2},
- {3, 3}
- };
- }
-
- @DataProvider (name = "long-same-numbers-provider")
- public Object[][] createSameLong () {
- return new Object[][]{
- {1L, 1L},
- {2L, 2L},
- {3L, 3L}
- };
- }
-
- @DataProvider (name = "short-same-numbers-provider")
- public Object[][] createSameShort () {
- return new Object[][]{
- {SHORT1, SHORT1},
- {SHORT2, SHORT2},
- {SHORT3, SHORT3}
- };
- }
-
- @DataProvider (name = "bigdecimal-smaller-numbers-provider")
- public Object[][] createSmallerBigDecimal () {
- return new Object[][]{
- {new BigDecimal(2), new BigDecimal(1)},
- {new BigDecimal(3), new BigDecimal(2)},
- {new BigDecimal(4), new BigDecimal(3)}
- };
- }
-
- @DataProvider (name = "int-smaller-numbers-provider")
- public Object[][] createSmallerInteger () {
- return new Object[][]{
- {2, 1},
- {3, 2},
- {4, 3}
- };
- }
-
- @DataProvider (name = "long-smaller-numbers-provider")
- public Object[][] createSmallerLong () {
- return new Object[][]{
- {2L, 1L},
- {3L, 2L},
- {4L, 3L}
- };
- }
-
- @DataProvider (name = "short-smaller-numbers-provider")
- public Object[][] createSmallerShort () {
- return new Object[][]{
- {SHORT2, SHORT1},
- {SHORT3, SHORT2},
- {SHORT4, SHORT3}
- };
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with larger", dataProvider = "int-larger-numbers-provider")
- public void testCompareLarger (final Integer var1, final Integer var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with larger", dataProvider = "long-larger-numbers-provider")
- public void testCompareLarger (final Long var1, final Long var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with larger numbers", dataProvider = "short-larger-numbers-provider")
- public void testCompareLarger (final Short var1, final Short var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with larger numbers", dataProvider = "bigdecimal-larger-numbers-provider")
- public void testCompareLarger (final BigDecimal var1, final BigDecimal var2) {
- // All compare() should always return 1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with left null numbers", dataProvider = "int-left-null-numbers-provider")
- public void testCompareLeftNull (final Integer var1, final Integer var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with left null numbers", dataProvider = "long-left-null-numbers-provider")
- public void testCompareLeftNull (final Long var1, final Long var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with left null numbers", dataProvider = "short-left-null-numbers-provider")
- public void testCompareLeftNull (final Short var1, final Short var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with left null numbers", dataProvider = "bigdecimal-left-null-numbers-provider")
- public void testCompareLeftNull (final BigDecimal var1, final BigDecimal var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), -1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with right null numbers", dataProvider = "int-right-null-numbers-provider")
- public void testCompareRightNull (final Integer var1, final Integer var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with right null numbers", dataProvider = "long-right-null-numbers-provider")
- public void testCompareRightNull (final Long var1, final Long var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with right null numbers", dataProvider = "short-right-null-numbers-provider")
- public void testCompareRightNull (final Short var1, final Short var2) {
- // All compare() should always return 1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with right null numbers", dataProvider = "bigdecimal-right-null-numbers-provider")
- public void testCompareRightNull (final BigDecimal var1, final BigDecimal var2) {
- // All compare() should always return 1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with same numbers", dataProvider = "int-same-numbers-provider")
- public void testCompareSame (final Integer var1, final Integer var2) {
- // All compare() should always return 0
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 0);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with same numbers", dataProvider = "long-same-numbers-provider")
- public void testCompareSame (final Long var1, final Long var2) {
- // All compare() should always return 0
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 0);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with same numbers", dataProvider = "short-same-numbers-provider")
- public void testCompareSame (final Short var1, final Short var2) {
- // All compare() should always return -1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 0);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with same numbers", dataProvider = "bigdecimal-same-numbers-provider")
- public void testCompareSame (final BigDecimal var1, final BigDecimal var2) {
- // All compare() should always return 0
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 0);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Integer,Integer) with smaller numbers", dataProvider = "int-smaller-numbers-provider")
- public void testCompareSmaller (final Integer var1, final Integer var2) {
- // All compare() should always return 1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Long,Long) with smaller numbers", dataProvider = "long-smaller-numbers-provider")
- public void testCompareSmaller (final Long var1, final Long var2) {
- // All compare() should always return 1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(Short,Short) with smaller numbers", dataProvider = "short-smaller-numbers-provider")
- public void testCompareSmaller (final Short var1, final Short var2) {
- // All compare() should always return 1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
- }
-
- @Test (description = "Tests method SafeNumberUtils.compare(BigDecimal,BigDecimal) with smaller numbers", dataProvider = "bigdecimal-smaller-numbers-provider")
- public void testCompareSmaller (final BigDecimal var1, final BigDecimal var2) {
- // All compare() should always return 1
- Assert.assertEquals(SafeNumberUtils.compare(var1, var2), 1);
- }
-
-}