add tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901352 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-05-28 14:13:25 +00:00
parent 1b0fac992c
commit 23622343ce
2 changed files with 46 additions and 0 deletions

View File

@ -66,6 +66,16 @@ public class TestStdev {
}
}
@Test
void testStringsWithNums() throws IOException {
try (HSSFWorkbook wb = initWorkbook3()) {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(12);
assertDouble(fe, cell, "STDEVA(A2:A7)", 4.546060565661952, 0.00000000001);
assertDouble(fe, cell, "STDEV(A2:A7)", 3.559026084010437, 0.00000000001);
}
}
private HSSFWorkbook initWorkbook1() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
@ -96,4 +106,17 @@ public class TestStdev {
addRow(sheet, 6, false);
return wb;
}
private HSSFWorkbook initWorkbook3() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
addRow(sheet, 0, "Data");
addRow(sheet, 1, 10);
addRow(sheet, 2, 7);
addRow(sheet, 3, 9);
addRow(sheet, 4, 2);
addRow(sheet, 5, "4.5");
addRow(sheet, 6, "14");
return wb;
}
}

View File

@ -65,6 +65,16 @@ public class TestVar {
}
}
@Test
void testStringsWithNums() throws IOException {
try (HSSFWorkbook wb = initWorkbook3()) {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(12);
assertDouble(fe, cell, "VARA(A2:A7)", 20.666666666666668, 0.00000000001);
assertDouble(fe, cell, "VAR(A2:A7)", 12.666666666666666, 0.00000000001);
}
}
private HSSFWorkbook initWorkbook1() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
@ -95,4 +105,17 @@ public class TestVar {
addRow(sheet, 6, false);
return wb;
}
private HSSFWorkbook initWorkbook3() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
addRow(sheet, 0, "Data");
addRow(sheet, 1, 10);
addRow(sheet, 2, 7);
addRow(sheet, 3, 9);
addRow(sheet, 4, 2);
addRow(sheet, 5, "4.5");
addRow(sheet, 6, "14");
return wb;
}
}