From faa2a64d4af6e89b62bba899bfe1040675765a5a Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Sun, 4 May 2014 21:17:18 +0000 Subject: Bug 56269 - DateFormat - Rounding of fractionals git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1592419 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/usermodel/TestHSSFDateUtil.java | 74 ++++++++++++++++------ 1 file changed, 53 insertions(+), 21 deletions(-) (limited to 'src/testcases/org') diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java index 6733f73fa2..022975d9ae 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java @@ -17,15 +17,18 @@ package org.apache.poi.hssf.usermodel; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; -import junit.framework.TestCase; - import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.model.InternalWorkbook; +import org.junit.Test; /** * Class TestHSSFDateUtil @@ -37,7 +40,7 @@ import org.apache.poi.hssf.model.InternalWorkbook; * @author Alex Jacoby (ajacoby at gmail.com) * @version %I%, %G% */ -public final class TestHSSFDateUtil extends TestCase { +public final class TestHSSFDateUtil { public static final int CALENDAR_JANUARY = 0; public static final int CALENDAR_FEBRUARY = 1; @@ -49,8 +52,8 @@ public final class TestHSSFDateUtil extends TestCase { /** * Checks the date conversion functions in the HSSFDateUtil class. */ - - public void testDateConversion() { + @Test + public void dateConversion() { // Iteratating over the hours exposes any rounding issues. for (int hour = 0; hour < 23; hour++) @@ -87,7 +90,8 @@ public final class TestHSSFDateUtil extends TestCase { * Checks the conversion of a java.util.date to Excel on a day when * Daylight Saving Time starts. */ - public void testExcelConversionOnDSTStart() { + @Test + public void excelConversionOnDSTStart() { TimeZone cet = TimeZone.getTimeZone("Europe/Copenhagen"); TimeZone.setDefault(cet); Calendar cal = new GregorianCalendar(2004, CALENDAR_MARCH, 28); @@ -117,7 +121,8 @@ public final class TestHSSFDateUtil extends TestCase { * Checks the conversion of an Excel date to a java.util.date on a day when * Daylight Saving Time starts. */ - public void testJavaConversionOnDSTStart() { + @Test + public void javaConversionOnDSTStart() { TimeZone cet = TimeZone.getTimeZone("Europe/Copenhagen"); TimeZone.setDefault(cet); Calendar cal = new GregorianCalendar(2004, CALENDAR_MARCH, 28); @@ -144,7 +149,8 @@ public final class TestHSSFDateUtil extends TestCase { * Checks the conversion of a java.util.Date to Excel on a day when * Daylight Saving Time ends. */ - public void testExcelConversionOnDSTEnd() { + @Test + public void excelConversionOnDSTEnd() { TimeZone cet = TimeZone.getTimeZone("Europe/Copenhagen"); TimeZone.setDefault(cet); Calendar cal = new GregorianCalendar(2004, CALENDAR_OCTOBER, 31); @@ -167,7 +173,8 @@ public final class TestHSSFDateUtil extends TestCase { * Checks the conversion of an Excel date to java.util.Date on a day when * Daylight Saving Time ends. */ - public void testJavaConversionOnDSTEnd() { + @Test + public void javaConversionOnDSTEnd() { TimeZone cet = TimeZone.getTimeZone("Europe/Copenhagen"); TimeZone.setDefault(cet); Calendar cal = new GregorianCalendar(2004, CALENDAR_OCTOBER, 31); @@ -186,7 +193,8 @@ public final class TestHSSFDateUtil extends TestCase { /** * Tests that we deal with time-zones properly */ - public void testCalendarConversion() { + @Test + public void calendarConversion() { GregorianCalendar date = new GregorianCalendar(2002, 0, 1, 12, 1, 1); Date expected = date.getTime(); @@ -226,7 +234,8 @@ public final class TestHSSFDateUtil extends TestCase { /** * Tests that we correctly detect date formats as such */ - public void testIdentifyDateFormats() { + @Test + public void identifyDateFormats() { // First up, try with a few built in date formats short[] builtins = new short[] { 0x0e, 0x0f, 0x10, 0x16, 0x2d, 0x2e }; for(int i=0; i