aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2015-05-20 18:00:19 +0000
committerDominik Stadler <centic@apache.org>2015-05-20 18:00:19 +0000
commitf3872cbcf4a307a3f9ba713a1ddf44792cb2e7e8 (patch)
tree50ea1f90588e27e2995465d68eef50882ce6ab71 /src/testcases/org/apache/poi/hssf
parent5209d15d1c2d12346ba57fdc41267ffd4e45a1f0 (diff)
downloadpoi-f3872cbcf4a307a3f9ba713a1ddf44792cb2e7e8.tar.gz
poi-f3872cbcf4a307a3f9ba713a1ddf44792cb2e7e8.zip
Apply fix reported in bug 47661 and add unit tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1680642 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
index f5ea7a1ccc..2e34d6f602 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
@@ -17,9 +17,7 @@
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 static org.junit.Assert.*;
import java.io.IOException;
import java.text.ParseException;
@@ -349,6 +347,7 @@ public final class TestHSSFDateUtil {
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("DateFormats.xls");
HSSFSheet sheet = workbook.getSheetAt(0);
InternalWorkbook wb = workbook.getWorkbook();
+ assertNotNull(wb);
HSSFRow row;
HSSFCell cell;
@@ -482,6 +481,25 @@ public final class TestHSSFDateUtil {
}
@Test
+ public void absoluteDayYearTooLow() {
+ GregorianCalendar calendar = new GregorianCalendar(1899, 0, 1);
+ try {
+ HSSFDateUtil.absoluteDay(calendar, false);
+ fail("Should fail here");
+ } catch (IllegalArgumentException e) {
+ // expected here
+ }
+
+ try {
+ calendar = new GregorianCalendar(1903, 0, 1);
+ HSSFDateUtil.absoluteDay(calendar, true);
+ fail("Should fail here");
+ } catch (IllegalArgumentException e) {
+ // expected here
+ }
+ }
+
+ @Test
public void convertTime() {
final double delta = 1E-7; // a couple of digits more accuracy than strictly required