diff options
author | Cédric Walter <cedricwalter@apache.org> | 2013-10-10 21:54:52 +0000 |
---|---|---|
committer | Cédric Walter <cedricwalter@apache.org> | 2013-10-10 21:54:52 +0000 |
commit | c7fecc7c213c0b3836f9978e01b3c520627eeb50 (patch) | |
tree | a827f5d44a91b3934c2a60d56b084872ec78fec3 /src/testcases/org/apache/poi/ss | |
parent | b34a3eefa7662cd666d360facd65af20e298298a (diff) | |
download | poi-c7fecc7c213c0b3836f9978e01b3c520627eeb50.tar.gz poi-c7fecc7c213c0b3836f9978e01b3c520627eeb50.zip |
Bug 55649: WORKDAY Function returns incorrect date when spanning a weekend, or the start date is a weekend
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1531124 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss')
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/atp/TestWorkdayFunction.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ss/formula/atp/TestWorkdayFunction.java b/src/testcases/org/apache/poi/ss/formula/atp/TestWorkdayFunction.java index 6540de028a..b71e0c312c 100644 --- a/src/testcases/org/apache/poi/ss/formula/atp/TestWorkdayFunction.java +++ b/src/testcases/org/apache/poi/ss/formula/atp/TestWorkdayFunction.java @@ -85,6 +85,46 @@ public class TestWorkdayFunction extends TestCase { new StringEval(STARTING_DATE.toString()), new NumberEval(151) }, EC)).getNumberValue())); } + public void testReturnWorkdaysSpanningAWeekendSubtractingDays() { + String startDate = "2013/09/30"; + int days = -1; + String expectedWorkDay = "2013/09/27"; + StringEval stringEval = new StringEval(startDate); + double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(new ValueEval[]{ + stringEval, new NumberEval(days) }, EC)).getNumberValue(); + assertEquals(expectedWorkDay, formatter.format(DateUtil.getJavaDate(numberValue))); + } + + public void testReturnWorkdaysSpanningAWeekendAddingDays() { + String startDate = "2013/09/27"; + int days = 1; + String expectedWorkDay = "2013/09/30"; + StringEval stringEval = new StringEval(startDate); + double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(new ValueEval[]{ + stringEval, new NumberEval(days) }, EC)).getNumberValue(); + assertEquals(expectedWorkDay, formatter.format(DateUtil.getJavaDate(numberValue))); + } + + public void testReturnWorkdaysWhenStartIsWeekendAddingDays() { + String startDate = "2013/10/06"; + int days = 1; + String expectedWorkDay = "2013/10/07"; + StringEval stringEval = new StringEval(startDate); + double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(new ValueEval[]{ + stringEval, new NumberEval(days) }, EC)).getNumberValue(); + assertEquals(expectedWorkDay, formatter.format(DateUtil.getJavaDate(numberValue))); + } + + public void testReturnWorkdaysWhenStartIsWeekendSubtractingDays() { + String startDate = "2013/10/06"; + int days = -1; + String expectedWorkDay = "2013/10/04"; + StringEval stringEval = new StringEval(startDate); + double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(new ValueEval[]{ + stringEval, new NumberEval(days) }, EC)).getNumberValue(); + assertEquals(expectedWorkDay, formatter.format(DateUtil.getJavaDate(numberValue))); + } + public void testReturnWorkdaysWithDaysTruncated() { assertEquals(new Date(109, APRIL, 30), DateUtil.getJavaDate(((NumberEval) WorkdayFunction.instance.evaluate(new ValueEval[]{ new StringEval(STARTING_DATE.toString()), new NumberEval(151.99999) }, EC)).getNumberValue())); |