001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.core.util;
017:
018: import org.kuali.kfs.context.KualiTestBase;
019:
020: /**
021: * This class tests the NumberUtils methods.
022: */
023: public class NumberUtilsTest extends KualiTestBase {
024:
025: public final void testIntValue_nullInteger() {
026: Integer testInteger = null;
027: int testInt = 123;
028:
029: int intValue = NumberUtils.intValue(testInteger, testInt);
030: assertEquals(intValue, testInt);
031: }
032:
033: public final void testIntValue_nonNullInteger() {
034: Integer testInteger = new Integer(456);
035: int testInt = 123;
036:
037: int intValue = NumberUtils.intValue(testInteger, testInt);
038: assertEquals(intValue, 456);
039: }
040:
041: public final void testIntegerEquals_bothNull() {
042: assertTrue(NumberUtils.equals((Integer) null, (Integer) null));
043: }
044:
045: public final void testIntegerEquals_bothNonNull_inequal() {
046: Integer i = new Integer(0);
047: Integer j = new Integer(1);
048:
049: assertFalse(NumberUtils.equals(i, j));
050: }
051:
052: public final void testIntegerEquals_bothNonNull_equal() {
053: Integer i = new Integer(2);
054: Integer j = new Integer(2);
055:
056: assertTrue(NumberUtils.equals(i, j));
057: }
058:
059: public final void testIntegerEquals_firstNotNull() {
060: Integer i = new Integer(3);
061: Integer j = null;
062:
063: assertFalse(NumberUtils.equals(i, j));
064: }
065:
066: public final void testIntegerEquals_secondNotNull() {
067: Integer i = null;
068: Integer j = new Integer(4);
069:
070: assertFalse(NumberUtils.equals(i, j));
071: }
072:
073: public final void testKualiDecimalEquals_bothNull() {
074: assertTrue(NumberUtils.equals((KualiDecimal) null,
075: (KualiDecimal) null));
076: }
077:
078: public final void testKualiDecimalEquals_bothNonNull_inequal() {
079: KualiDecimal i = new KualiDecimal(0);
080: KualiDecimal j = new KualiDecimal(1);
081:
082: assertFalse(NumberUtils.equals(i, j));
083: }
084:
085: public final void testKualiDecimalEquals_bothNonNull_equal() {
086: KualiDecimal i = new KualiDecimal(2);
087: KualiDecimal j = new KualiDecimal(2);
088:
089: assertTrue(NumberUtils.equals(i, j));
090: }
091:
092: public final void testKualiDecimalEquals_firstNotNull() {
093: KualiDecimal i = new KualiDecimal(3);
094: KualiDecimal j = null;
095:
096: assertFalse(NumberUtils.equals(i, j));
097: }
098:
099: public final void testKualiDecimalEquals_secondNotNull() {
100: KualiDecimal i = null;
101: KualiDecimal j = new KualiDecimal(4);
102:
103: assertFalse(NumberUtils.equals(i, j));
104: }
105: }
|