001: /* ========================================================================
002: * JCommon : a free general purpose class library for the Java(tm) platform
003: * ========================================================================
004: *
005: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006: *
007: * Project Info: http://www.jfree.org/jcommon/index.html
008: *
009: * This library is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU Lesser General Public License as published by
011: * the Free Software Foundation; either version 2.1 of the License, or
012: * (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but
015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017: * License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022: * USA.
023: *
024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * -----------------------------
028: * SerialDateUtilitiesTests.java
029: * -----------------------------
030: * (C) Copyright 2002, 2003, by Object Refinery Limited.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): -;
034: *
035: * $Id: SerialDateUtilitiesTests.java,v 1.4 2005/11/16 15:58:40 taqua Exp $
036: *
037: * Changes
038: * -------
039: * 25-Jun-2002 : Version 1 (DG);
040: * 24-Oct-2002 : Fixed errors reported by Checkstyle (DG);
041: *
042: */
043:
044: package org.jfree.date.junit;
045:
046: import junit.framework.Test;
047: import junit.framework.TestCase;
048: import junit.framework.TestSuite;
049:
050: import org.jfree.date.MonthConstants;
051: import org.jfree.date.SerialDate;
052: import org.jfree.date.SerialDateUtilities;
053:
054: /**
055: * Some tests for the SerialDateUtilities class.
056: *
057: */
058: public class SerialDateUtilitiesTests extends TestCase {
059:
060: /**
061: * Creates a new test case.
062: *
063: * @param name the name.
064: */
065: public SerialDateUtilitiesTests(final String name) {
066: super (name);
067: }
068:
069: /**
070: * Returns a test suite for the JUnit test runner.
071: *
072: * @return the test suite.
073: */
074: public static Test suite() {
075: return new TestSuite(SerialDateUtilitiesTests.class);
076: }
077:
078: /**
079: * Problem actual day count.
080: */
081: public void testDayCountActual() {
082: final SerialDate d1 = SerialDate.createInstance(1,
083: MonthConstants.APRIL, 2002);
084: final SerialDate d2 = SerialDate.createInstance(2,
085: MonthConstants.APRIL, 2002);
086: final int count = SerialDateUtilities.dayCountActual(d1, d2);
087: assertEquals(1, count);
088: }
089:
090: /**
091: * Problem 30/360 day count.
092: */
093: public void testDayCount30() {
094: final SerialDate d1 = SerialDate.createInstance(1,
095: MonthConstants.APRIL, 2002);
096: final SerialDate d2 = SerialDate.createInstance(2,
097: MonthConstants.APRIL, 2002);
098: final int count = SerialDateUtilities.dayCount30(d1, d2);
099: assertEquals(1, count);
100: }
101:
102: /**
103: * Problem 30/360ISDA day count.
104: */
105: public void testDayCount30ISDA() {
106: final SerialDate d1 = SerialDate.createInstance(1,
107: MonthConstants.APRIL, 2002);
108: final SerialDate d2 = SerialDate.createInstance(2,
109: MonthConstants.APRIL, 2002);
110: final int count = SerialDateUtilities.dayCount30ISDA(d1, d2);
111: assertEquals(1, count);
112: }
113:
114: /**
115: * Problem 30/360PSA day count.
116: */
117: public void testDayCount30PSA() {
118: final SerialDate d1 = SerialDate.createInstance(1,
119: MonthConstants.APRIL, 2002);
120: final SerialDate d2 = SerialDate.createInstance(2,
121: MonthConstants.APRIL, 2002);
122: final int count = SerialDateUtilities.dayCount30PSA(d1, d2);
123: assertEquals(1, count);
124: }
125:
126: /**
127: * Problem 30E/360 day count.
128: */
129: public void testDayCount3030E() {
130: final SerialDate d1 = SerialDate.createInstance(1,
131: MonthConstants.APRIL, 2002);
132: final SerialDate d2 = SerialDate.createInstance(2,
133: MonthConstants.APRIL, 2002);
134: final int count = SerialDateUtilities.dayCount30E(d1, d2);
135: assertEquals(1, count);
136: }
137:
138: }
|