add weekday tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1893858 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2021-10-03 17:07:22 +00:00
parent cd31c9c275
commit 99fe7a9635
2 changed files with 14 additions and 2 deletions

View File

@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests WEEKNUM(date[, return_type]) excep function
* Tests WEEKNUM(date[, return_type]) excel function
* https://support.microsoft.com/en-us/office/weeknum-function-e5c43a03-b4ab-426c-b411-b18c13c75340
*/
class TestWeekNumFunc {

View File

@ -18,13 +18,16 @@
package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.eval.*;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.util.StringUtil;
import org.junit.jupiter.api.Test;
import java.time.LocalDate;
import static org.junit.jupiter.api.Assertions.*;
/**
* Tests WEEKDAY(serial_number[, return_type]) excep function
* Tests WEEKDAY(serial_number[, return_type]) excel function
* https://support.office.com/en-us/article/WEEKDAY-function-60E44483-2ED1-439F-8BD0-E404C190949A
*/
class TestWeekdayFunc {
@ -71,6 +74,15 @@ class TestWeekdayFunc {
assertEvaluateEquals(3.0, 39448.0, 17.0);
}
@Test
void testMicrosoftExamples() {
double date = DateUtil.getExcelDate(LocalDate.parse("2008-02-14"));
assertEvaluateEquals(5.0, date);
assertEvaluateEquals(4.0, date, 2);
assertEvaluateEquals(3.0, date, 3);
}
// for testing invalid invocations
private void assertEvaluateEquals(String message, ErrorEval expected, ValueEval... args) {
String formula = "WEEKDAY(" + StringUtil.join(args, ", ") + ")";