You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 20:56:49 UTC

svn commit: r1890120 [42/43] - in /poi/trunk/poi/src: main/java/org/apache/poi/ main/java/org/apache/poi/ddf/ main/java/org/apache/poi/extractor/ main/java/org/apache/poi/hpsf/ main/java/org/apache/poi/hssf/ main/java/org/apache/poi/hssf/dev/ main/java...

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestTime.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestTime.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestTime.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestTime.java Sat May 22 20:56:44 2021
@@ -36,89 +36,89 @@ import org.junit.jupiter.api.Test;
  */
 final class TestTime {
 
-	private static final int SECONDS_PER_MINUTE = 60;
-	private static final int SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE;
-	private static final double SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
-	private HSSFCell cell11;
-	private HSSFFormulaEvaluator evaluator;
-	private HSSFWorkbook wb;
-	private HSSFDataFormatter form;
-	private HSSFCellStyle style;
-
-	@BeforeEach
-	void setUp() {
-		wb = new HSSFWorkbook();
-		HSSFSheet sheet = wb.createSheet("new sheet");
-		style = wb.createCellStyle();
-		HSSFDataFormat fmt = wb.createDataFormat();
-		style.setDataFormat(fmt.getFormat("hh:mm:ss"));
-
-		cell11 = sheet.createRow(0).createCell(0);
-		form = new HSSFDataFormatter();
-
-		evaluator = new HSSFFormulaEvaluator(wb);
-	}
-
-	@Test
-	void testSomeArgumentsMissing() {
-		confirm("00:00:00", "TIME(, 0, 0)");
-		confirm("12:00:00", "TIME(12, , )");
-	}
-
-	@Test
-	void testValid() {
-		confirm("00:00:01", 0, 0, 1);
-		confirm("00:01:00", 0, 1, 0);
-
-		confirm("00:00:00", 0, 0, 0);
-
-		confirm("01:00:00", 1, 0, 0);
-		confirm("12:00:00", 12, 0, 0);
-		confirm("23:00:00", 23, 0, 0);
-		confirm("00:00:00", 24, 0, 0);
-		confirm("01:00:00", 25, 0, 0);
-		confirm("00:00:00", 48, 0, 0);
-		confirm("06:00:00", 6, 0, 0);
-		confirm("06:01:00", 6, 1, 0);
-		confirm("06:30:00", 6, 30, 0);
-
-		confirm("06:59:00", 6, 59, 0);
-		confirm("07:00:00", 6, 60, 0);
-		confirm("07:01:00", 6, 61, 0);
-		confirm("08:00:00", 6, 120, 0);
-		confirm("06:00:00", 6, 1440, 0);
-		confirm("18:49:00", 18, 49, 0);
-		confirm("18:49:01", 18, 49, 1);
-		confirm("18:49:30", 18, 49, 30);
-		confirm("18:49:59", 18, 49, 59);
-		confirm("18:50:00", 18, 49, 60);
-		confirm("18:50:01", 18, 49, 61);
-		confirm("18:50:59", 18, 49, 119);
-		confirm("18:51:00", 18, 49, 120);
-		confirm("03:55:07", 18, 49, 32767);
-		confirm("12:08:01", 18, 32767, 61);
-		confirm("07:50:01", 32767, 49, 61);
-	}
-	private void confirm(String expectedTimeStr, int inH, int inM, int inS) {
-		confirm(expectedTimeStr, "TIME(" + inH + "," + inM + "," + inS + ")");
-	}
-
-	private void confirm(String expectedTimeStr, String formulaText) {
-		String[] parts = Pattern.compile(":").split(expectedTimeStr);
-		int expH = Integer.parseInt(parts[0]);
-		int expM = Integer.parseInt(parts[1]);
-		int expS = Integer.parseInt(parts[2]);
-
-		double expectedValue = (expH*SECONDS_PER_HOUR + expM*SECONDS_PER_MINUTE + expS)/SECONDS_PER_DAY;
-
-		cell11.setCellFormula(formulaText);
-		cell11.setCellStyle(style);
-		evaluator.clearAllCachedResultValues();
-
-		double actualValue = evaluator.evaluate(cell11).getNumberValue();
-		assertEquals(expectedValue, actualValue, 0.0);
-
-		String actualText = form.formatCellValue(cell11, evaluator);
-		assertEquals(expectedTimeStr, actualText);
-	}
+    private static final int SECONDS_PER_MINUTE = 60;
+    private static final int SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE;
+    private static final double SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
+    private HSSFCell cell11;
+    private HSSFFormulaEvaluator evaluator;
+    private HSSFWorkbook wb;
+    private HSSFDataFormatter form;
+    private HSSFCellStyle style;
+
+    @BeforeEach
+    void setUp() {
+        wb = new HSSFWorkbook();
+        HSSFSheet sheet = wb.createSheet("new sheet");
+        style = wb.createCellStyle();
+        HSSFDataFormat fmt = wb.createDataFormat();
+        style.setDataFormat(fmt.getFormat("hh:mm:ss"));
+
+        cell11 = sheet.createRow(0).createCell(0);
+        form = new HSSFDataFormatter();
+
+        evaluator = new HSSFFormulaEvaluator(wb);
+    }
+
+    @Test
+    void testSomeArgumentsMissing() {
+        confirm("00:00:00", "TIME(, 0, 0)");
+        confirm("12:00:00", "TIME(12, , )");
+    }
+
+    @Test
+    void testValid() {
+        confirm("00:00:01", 0, 0, 1);
+        confirm("00:01:00", 0, 1, 0);
+
+        confirm("00:00:00", 0, 0, 0);
+
+        confirm("01:00:00", 1, 0, 0);
+        confirm("12:00:00", 12, 0, 0);
+        confirm("23:00:00", 23, 0, 0);
+        confirm("00:00:00", 24, 0, 0);
+        confirm("01:00:00", 25, 0, 0);
+        confirm("00:00:00", 48, 0, 0);
+        confirm("06:00:00", 6, 0, 0);
+        confirm("06:01:00", 6, 1, 0);
+        confirm("06:30:00", 6, 30, 0);
+
+        confirm("06:59:00", 6, 59, 0);
+        confirm("07:00:00", 6, 60, 0);
+        confirm("07:01:00", 6, 61, 0);
+        confirm("08:00:00", 6, 120, 0);
+        confirm("06:00:00", 6, 1440, 0);
+        confirm("18:49:00", 18, 49, 0);
+        confirm("18:49:01", 18, 49, 1);
+        confirm("18:49:30", 18, 49, 30);
+        confirm("18:49:59", 18, 49, 59);
+        confirm("18:50:00", 18, 49, 60);
+        confirm("18:50:01", 18, 49, 61);
+        confirm("18:50:59", 18, 49, 119);
+        confirm("18:51:00", 18, 49, 120);
+        confirm("03:55:07", 18, 49, 32767);
+        confirm("12:08:01", 18, 32767, 61);
+        confirm("07:50:01", 32767, 49, 61);
+    }
+    private void confirm(String expectedTimeStr, int inH, int inM, int inS) {
+        confirm(expectedTimeStr, "TIME(" + inH + "," + inM + "," + inS + ")");
+    }
+
+    private void confirm(String expectedTimeStr, String formulaText) {
+        String[] parts = Pattern.compile(":").split(expectedTimeStr);
+        int expH = Integer.parseInt(parts[0]);
+        int expM = Integer.parseInt(parts[1]);
+        int expS = Integer.parseInt(parts[2]);
+
+        double expectedValue = (expH*SECONDS_PER_HOUR + expM*SECONDS_PER_MINUTE + expS)/SECONDS_PER_DAY;
+
+        cell11.setCellFormula(formulaText);
+        cell11.setCellStyle(style);
+        evaluator.clearAllCachedResultValues();
+
+        double actualValue = evaluator.evaluate(cell11).getNumberValue();
+        assertEquals(expectedValue, actualValue, 0.0);
+
+        String actualText = form.formatCellValue(cell11, evaluator);
+        assertEquals(expectedTimeStr, actualText);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestTrim.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestTrim.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestTrim.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestTrim.java Sat May 22 20:56:44 2021
@@ -33,49 +33,49 @@ import org.junit.jupiter.api.Test;
 final class TestTrim {
 
 
-	private static ValueEval invokeTrim(ValueEval text) {
-		ValueEval[] args = new ValueEval[] { text, };
-		return TextFunction.TRIM.evaluate(args, -1, (short)-1);
-	}
-
-	private void confirmTrim(ValueEval text, String expected) {
-		ValueEval result = invokeTrim(text);
-		assertEquals(StringEval.class, result.getClass());
-		assertEquals(expected, ((StringEval)result).getStringValue());
-	}
-
-	private void confirmTrim(ValueEval text, ErrorEval expectedError) {
-		ValueEval result = invokeTrim(text);
-		assertEquals(ErrorEval.class, result.getClass());
-		assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
-	}
-
-	@Test
-	void testBasic() {
-
-		confirmTrim(new StringEval(" hi "), "hi");
-		confirmTrim(new StringEval("hi "), "hi");
-		confirmTrim(new StringEval("  hi"), "hi");
-		confirmTrim(new StringEval(" hi there  "), "hi there");
-		confirmTrim(new StringEval(""), "");
-		confirmTrim(new StringEval("   "), "");
-	}
-
-	/**
-	 * Valid cases where text arg is not exactly a string
-	 */
-	@Test
-	void testUnusualArgs() {
-
-		// text (first) arg type is number, other args are strings with fractional digits
-		confirmTrim(new NumberEval(123456), "123456");
-		confirmTrim(BoolEval.FALSE, "FALSE");
-		confirmTrim(BoolEval.TRUE, "TRUE");
-		confirmTrim(BlankEval.instance, "");
-	}
-
-	@Test
-	void testErrors() {
-		confirmTrim(ErrorEval.NAME_INVALID, ErrorEval.NAME_INVALID);
-	}
+    private static ValueEval invokeTrim(ValueEval text) {
+        ValueEval[] args = new ValueEval[] { text, };
+        return TextFunction.TRIM.evaluate(args, -1, (short)-1);
+    }
+
+    private void confirmTrim(ValueEval text, String expected) {
+        ValueEval result = invokeTrim(text);
+        assertEquals(StringEval.class, result.getClass());
+        assertEquals(expected, ((StringEval)result).getStringValue());
+    }
+
+    private void confirmTrim(ValueEval text, ErrorEval expectedError) {
+        ValueEval result = invokeTrim(text);
+        assertEquals(ErrorEval.class, result.getClass());
+        assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
+    }
+
+    @Test
+    void testBasic() {
+
+        confirmTrim(new StringEval(" hi "), "hi");
+        confirmTrim(new StringEval("hi "), "hi");
+        confirmTrim(new StringEval("  hi"), "hi");
+        confirmTrim(new StringEval(" hi there  "), "hi there");
+        confirmTrim(new StringEval(""), "");
+        confirmTrim(new StringEval("   "), "");
+    }
+
+    /**
+     * Valid cases where text arg is not exactly a string
+     */
+    @Test
+    void testUnusualArgs() {
+
+        // text (first) arg type is number, other args are strings with fractional digits
+        confirmTrim(new NumberEval(123456), "123456");
+        confirmTrim(BoolEval.FALSE, "FALSE");
+        confirmTrim(BoolEval.TRUE, "TRUE");
+        confirmTrim(BlankEval.instance, "");
+    }
+
+    @Test
+    void testErrors() {
+        confirmTrim(ErrorEval.NAME_INVALID, ErrorEval.NAME_INVALID);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestValue.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestValue.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestValue.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestValue.java Sat May 22 20:56:44 2021
@@ -30,68 +30,68 @@ import org.junit.jupiter.api.Test;
  */
 final class TestValue {
 
-	private static ValueEval invokeValue(String strText) {
-		ValueEval[] args = new ValueEval[] { new StringEval(strText), };
-		return new Value().evaluate(args, -1, (short) -1);
-	}
-
-	private static void confirmValue(String strText, double expected) {
-		ValueEval result = invokeValue(strText);
-		assertEquals(NumberEval.class, result.getClass());
-		assertEquals(expected, ((NumberEval) result).getNumberValue(), 0.0);
-	}
-
-	private static void confirmValueError(String strText) {
-		ValueEval result = invokeValue(strText);
-		assertEquals(ErrorEval.class, result.getClass());
-		assertEquals(ErrorEval.VALUE_INVALID, result);
-	}
-
-	@Test
-	void testBasic() {
-
-		confirmValue("100", 100);
-		confirmValue("-2.3", -2.3);
-		confirmValue(".5", 0.5);
-		confirmValue(".5e2", 50);
-		confirmValue(".5e-2", 0.005);
-		confirmValue(".5e+2", 50);
-		confirmValue("+5", 5);
-		confirmValue("$1,000", 1000);
-		confirmValue("100.5e1", 1005);
-		confirmValue("1,0000", 10000);
-		confirmValue("1,000,0000", 10000000);
-		confirmValue("1,000,0000,00000", 1000000000000.0);
-		confirmValue(" 100 ", 100);
-		confirmValue(" + 100", 100);
-		confirmValue("10000", 10000);
-		confirmValue("$-5", -5);
-		confirmValue("$.5", 0.5);
-		confirmValue("123e+5", 12300000);
-		confirmValue("1,000e2", 100000);
-		confirmValue("$10e2", 1000);
-		confirmValue("$1,000e2", 100000);
+    private static ValueEval invokeValue(String strText) {
+        ValueEval[] args = new ValueEval[] { new StringEval(strText), };
+        return new Value().evaluate(args, -1, (short) -1);
+    }
+
+    private static void confirmValue(String strText, double expected) {
+        ValueEval result = invokeValue(strText);
+        assertEquals(NumberEval.class, result.getClass());
+        assertEquals(expected, ((NumberEval) result).getNumberValue(), 0.0);
+    }
+
+    private static void confirmValueError(String strText) {
+        ValueEval result = invokeValue(strText);
+        assertEquals(ErrorEval.class, result.getClass());
+        assertEquals(ErrorEval.VALUE_INVALID, result);
+    }
+
+    @Test
+    void testBasic() {
+
+        confirmValue("100", 100);
+        confirmValue("-2.3", -2.3);
+        confirmValue(".5", 0.5);
+        confirmValue(".5e2", 50);
+        confirmValue(".5e-2", 0.005);
+        confirmValue(".5e+2", 50);
+        confirmValue("+5", 5);
+        confirmValue("$1,000", 1000);
+        confirmValue("100.5e1", 1005);
+        confirmValue("1,0000", 10000);
+        confirmValue("1,000,0000", 10000000);
+        confirmValue("1,000,0000,00000", 1000000000000.0);
+        confirmValue(" 100 ", 100);
+        confirmValue(" + 100", 100);
+        confirmValue("10000", 10000);
+        confirmValue("$-5", -5);
+        confirmValue("$.5", 0.5);
+        confirmValue("123e+5", 12300000);
+        confirmValue("1,000e2", 100000);
+        confirmValue("$10e2", 1000);
+        confirmValue("$1,000e2", 100000);
         confirmValue("30%", 0.3);
         confirmValue("30 %", 0.3);
-	}
+    }
 
-	@Test
-	void testErrors() {
-		confirmValueError("1+1");
-		confirmValueError("1 1");
-		confirmValueError("1,00.0");
-		confirmValueError("1,00");
-		confirmValueError("$1,00.5e1");
-		confirmValueError("1,00.5e1");
-		confirmValueError("1,0,000");
-		confirmValueError("1,00,000");
-		confirmValueError("++100");
-		confirmValueError("$$5");
-		confirmValueError("-");
-		confirmValueError("+");
-		confirmValueError("$");
-		confirmValueError(",300");
-		confirmValueError("0.233,4");
-		confirmValueError("1e2.5");
-	}
+    @Test
+    void testErrors() {
+        confirmValueError("1+1");
+        confirmValueError("1 1");
+        confirmValueError("1,00.0");
+        confirmValueError("1,00");
+        confirmValueError("$1,00.5e1");
+        confirmValueError("1,00.5e1");
+        confirmValueError("1,0,000");
+        confirmValueError("1,00,000");
+        confirmValueError("++100");
+        confirmValueError("$$5");
+        confirmValueError("-");
+        confirmValueError("+");
+        confirmValueError("$");
+        confirmValueError(",300");
+        confirmValueError("0.233,4");
+        confirmValueError("1e2.5");
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestXYNumericFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestXYNumericFunction.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestXYNumericFunction.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestXYNumericFunction.java Sat May 22 20:56:44 2021
@@ -28,111 +28,111 @@ import org.junit.jupiter.api.Test;
  * Tests for Excel functions SUMX2MY2(), SUMX2PY2(), SUMXMY2()
  */
 final class TestXYNumericFunction {
-	private static final Function SUM_SQUARES = new Sumx2py2();
-	private static final Function DIFF_SQUARES = new Sumx2my2();
-	private static final Function SUM_SQUARES_OF_DIFFS = new Sumxmy2();
-
-	private static ValueEval invoke(Function function, ValueEval xArray, ValueEval yArray) {
-		ValueEval[] args = new ValueEval[] { xArray, yArray, };
-		return function.evaluate(args, -1, (short)-1);
-	}
-
-	private void confirm(Function function, ValueEval xArray, ValueEval yArray, double expected) {
-		ValueEval result = invoke(function, xArray, yArray);
-		assertEquals(NumberEval.class, result.getClass());
-		assertEquals(expected, ((NumberEval)result).getNumberValue(), 0);
-	}
-	private void confirmError(Function function, ValueEval xArray, ValueEval yArray, ErrorEval expectedError) {
-		ValueEval result = invoke(function, xArray, yArray);
-		assertEquals(ErrorEval.class, result.getClass());
-		assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
-	}
-
-	private void confirmError(ValueEval xArray, ValueEval yArray, ErrorEval expectedError) {
-		confirmError(SUM_SQUARES, xArray, yArray, expectedError);
-		confirmError(DIFF_SQUARES, xArray, yArray, expectedError);
-		confirmError(SUM_SQUARES_OF_DIFFS, xArray, yArray, expectedError);
-	}
-
-	@Test
-	void testBasic() {
-		ValueEval[] xValues = {
-			new NumberEval(1),
-			new NumberEval(2),
-		};
-		ValueEval areaEvalX = createAreaEval(xValues);
-		confirm(SUM_SQUARES, areaEvalX, areaEvalX, 10.0);
-		confirm(DIFF_SQUARES, areaEvalX, areaEvalX, 0.0);
-		confirm(SUM_SQUARES_OF_DIFFS, areaEvalX, areaEvalX, 0.0);
-
-		ValueEval[] yValues = {
-			new NumberEval(3),
-			new NumberEval(4),
-		};
-		ValueEval areaEvalY = createAreaEval(yValues);
-		confirm(SUM_SQUARES, areaEvalX, areaEvalY, 30.0);
-		confirm(DIFF_SQUARES, areaEvalX, areaEvalY, -20.0);
-		confirm(SUM_SQUARES_OF_DIFFS, areaEvalX, areaEvalY, 8.0);
-	}
-
-	/**
-	 * number of items in array is not limited to 30
-	 */
-	@Test
-	void testLargeArrays() {
-		ValueEval[] xValues = createMockNumberArray(100, 3);
-		ValueEval[] yValues = createMockNumberArray(100, 2);
-
-		confirm(SUM_SQUARES, createAreaEval(xValues), createAreaEval(yValues), 1300.0);
-		confirm(DIFF_SQUARES, createAreaEval(xValues), createAreaEval(yValues), 500.0);
-		confirm(SUM_SQUARES_OF_DIFFS, createAreaEval(xValues), createAreaEval(yValues), 100.0);
-	}
-
-
-	private ValueEval[] createMockNumberArray(int size, double value) {
-		ValueEval[] result = new ValueEval[size];
-		for (int i = 0; i < result.length; i++) {
-			result[i] = new NumberEval(value);
-		}
-		return result;
-	}
-
-	private static ValueEval createAreaEval(ValueEval[] values) {
-		String refStr = "A1:A" + values.length;
-		return EvalFactory.createAreaEval(refStr, values);
-	}
-
-	@Test
-	void testErrors() {
-		ValueEval[] xValues = {
-				ErrorEval.REF_INVALID,
-				new NumberEval(2),
-		};
-		ValueEval areaEvalX = createAreaEval(xValues);
-		ValueEval[] yValues = {
-				new NumberEval(2),
-				ErrorEval.NULL_INTERSECTION,
-		};
-		ValueEval areaEvalY = createAreaEval(yValues);
-		ValueEval[] zValues = { // wrong size
-				new NumberEval(2),
-		};
-		ValueEval areaEvalZ = createAreaEval(zValues);
-
-		// if either arg is an error, that error propagates
-		confirmError(ErrorEval.REF_INVALID, ErrorEval.NAME_INVALID, ErrorEval.REF_INVALID);
-		confirmError(areaEvalX, ErrorEval.NAME_INVALID, ErrorEval.NAME_INVALID);
-		confirmError(ErrorEval.NAME_INVALID, areaEvalX, ErrorEval.NAME_INVALID);
-
-		// array sizes must match
-		confirmError(areaEvalX, areaEvalZ, ErrorEval.NA);
-		confirmError(areaEvalZ, areaEvalY, ErrorEval.NA);
-
-		// any error in an array item propagates up
-		confirmError(areaEvalX, areaEvalX, ErrorEval.REF_INVALID);
-
-		// search for errors array by array, not pair by pair
-		confirmError(areaEvalX, areaEvalY, ErrorEval.REF_INVALID);
-		confirmError(areaEvalY, areaEvalX, ErrorEval.NULL_INTERSECTION);
-	}
+    private static final Function SUM_SQUARES = new Sumx2py2();
+    private static final Function DIFF_SQUARES = new Sumx2my2();
+    private static final Function SUM_SQUARES_OF_DIFFS = new Sumxmy2();
+
+    private static ValueEval invoke(Function function, ValueEval xArray, ValueEval yArray) {
+        ValueEval[] args = new ValueEval[] { xArray, yArray, };
+        return function.evaluate(args, -1, (short)-1);
+    }
+
+    private void confirm(Function function, ValueEval xArray, ValueEval yArray, double expected) {
+        ValueEval result = invoke(function, xArray, yArray);
+        assertEquals(NumberEval.class, result.getClass());
+        assertEquals(expected, ((NumberEval)result).getNumberValue(), 0);
+    }
+    private void confirmError(Function function, ValueEval xArray, ValueEval yArray, ErrorEval expectedError) {
+        ValueEval result = invoke(function, xArray, yArray);
+        assertEquals(ErrorEval.class, result.getClass());
+        assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
+    }
+
+    private void confirmError(ValueEval xArray, ValueEval yArray, ErrorEval expectedError) {
+        confirmError(SUM_SQUARES, xArray, yArray, expectedError);
+        confirmError(DIFF_SQUARES, xArray, yArray, expectedError);
+        confirmError(SUM_SQUARES_OF_DIFFS, xArray, yArray, expectedError);
+    }
+
+    @Test
+    void testBasic() {
+        ValueEval[] xValues = {
+            new NumberEval(1),
+            new NumberEval(2),
+        };
+        ValueEval areaEvalX = createAreaEval(xValues);
+        confirm(SUM_SQUARES, areaEvalX, areaEvalX, 10.0);
+        confirm(DIFF_SQUARES, areaEvalX, areaEvalX, 0.0);
+        confirm(SUM_SQUARES_OF_DIFFS, areaEvalX, areaEvalX, 0.0);
+
+        ValueEval[] yValues = {
+            new NumberEval(3),
+            new NumberEval(4),
+        };
+        ValueEval areaEvalY = createAreaEval(yValues);
+        confirm(SUM_SQUARES, areaEvalX, areaEvalY, 30.0);
+        confirm(DIFF_SQUARES, areaEvalX, areaEvalY, -20.0);
+        confirm(SUM_SQUARES_OF_DIFFS, areaEvalX, areaEvalY, 8.0);
+    }
+
+    /**
+     * number of items in array is not limited to 30
+     */
+    @Test
+    void testLargeArrays() {
+        ValueEval[] xValues = createMockNumberArray(100, 3);
+        ValueEval[] yValues = createMockNumberArray(100, 2);
+
+        confirm(SUM_SQUARES, createAreaEval(xValues), createAreaEval(yValues), 1300.0);
+        confirm(DIFF_SQUARES, createAreaEval(xValues), createAreaEval(yValues), 500.0);
+        confirm(SUM_SQUARES_OF_DIFFS, createAreaEval(xValues), createAreaEval(yValues), 100.0);
+    }
+
+
+    private ValueEval[] createMockNumberArray(int size, double value) {
+        ValueEval[] result = new ValueEval[size];
+        for (int i = 0; i < result.length; i++) {
+            result[i] = new NumberEval(value);
+        }
+        return result;
+    }
+
+    private static ValueEval createAreaEval(ValueEval[] values) {
+        String refStr = "A1:A" + values.length;
+        return EvalFactory.createAreaEval(refStr, values);
+    }
+
+    @Test
+    void testErrors() {
+        ValueEval[] xValues = {
+                ErrorEval.REF_INVALID,
+                new NumberEval(2),
+        };
+        ValueEval areaEvalX = createAreaEval(xValues);
+        ValueEval[] yValues = {
+                new NumberEval(2),
+                ErrorEval.NULL_INTERSECTION,
+        };
+        ValueEval areaEvalY = createAreaEval(yValues);
+        ValueEval[] zValues = { // wrong size
+                new NumberEval(2),
+        };
+        ValueEval areaEvalZ = createAreaEval(zValues);
+
+        // if either arg is an error, that error propagates
+        confirmError(ErrorEval.REF_INVALID, ErrorEval.NAME_INVALID, ErrorEval.REF_INVALID);
+        confirmError(areaEvalX, ErrorEval.NAME_INVALID, ErrorEval.NAME_INVALID);
+        confirmError(ErrorEval.NAME_INVALID, areaEvalX, ErrorEval.NAME_INVALID);
+
+        // array sizes must match
+        confirmError(areaEvalX, areaEvalZ, ErrorEval.NA);
+        confirmError(areaEvalZ, areaEvalY, ErrorEval.NA);
+
+        // any error in an array item propagates up
+        confirmError(areaEvalX, areaEvalX, ErrorEval.REF_INVALID);
+
+        // search for errors array by array, not pair by pair
+        confirmError(areaEvalX, areaEvalY, ErrorEval.REF_INVALID);
+        confirmError(areaEvalY, areaEvalX, ErrorEval.NULL_INTERSECTION);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestArea3DPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestArea3DPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestArea3DPtg.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestArea3DPtg.java Sat May 22 20:56:44 2021
@@ -30,24 +30,24 @@ import org.junit.jupiter.api.Test;
  */
 final class TestArea3DPtg extends BaseTestPtg {
 
-	/**
-	 * confirms that sheet names get properly escaped
-	 */
-	@Test
-	void testToFormulaString() throws IOException {
+    /**
+     * confirms that sheet names get properly escaped
+     */
+    @Test
+    void testToFormulaString() throws IOException {
 
-		Area3DPtg target = new Area3DPtg("A1:B1", (short)0);
+        Area3DPtg target = new Area3DPtg("A1:B1", (short)0);
 
-		String sheetName = "my sheet";
-		try (HSSFWorkbook wb = createWorkbookWithSheet(sheetName)) {
-			HSSFEvaluationWorkbook book = HSSFEvaluationWorkbook.create(wb);
-			assertEquals("'my sheet'!A1:B1", target.toFormulaString(book));
+        String sheetName = "my sheet";
+        try (HSSFWorkbook wb = createWorkbookWithSheet(sheetName)) {
+            HSSFEvaluationWorkbook book = HSSFEvaluationWorkbook.create(wb);
+            assertEquals("'my sheet'!A1:B1", target.toFormulaString(book));
 
-			wb.setSheetName(0, "Sheet1");
-			assertEquals("Sheet1!A1:B1", target.toFormulaString(book));
+            wb.setSheetName(0, "Sheet1");
+            assertEquals("Sheet1!A1:B1", target.toFormulaString(book));
 
-			wb.setSheetName(0, "C64");
-			assertEquals("'C64'!A1:B1", target.toFormulaString(book));
-		}
-	}
+            wb.setSheetName(0, "C64");
+            assertEquals("'C64'!A1:B1", target.toFormulaString(book));
+        }
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestAreaPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestAreaPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestAreaPtg.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestAreaPtg.java Sat May 22 20:56:44 2021
@@ -31,62 +31,62 @@ import org.junit.jupiter.api.Test;
  */
 final class TestAreaPtg {
 
-	AreaPtg relative;
-	AreaPtg absolute;
+    AreaPtg relative;
+    AreaPtg absolute;
 
-	@BeforeEach
-	void setUp() {
-		short firstRow=5;
-		short lastRow=13;
-		short firstCol=7;
-		short lastCol=17;
-		relative = new AreaPtg(firstRow,lastRow,firstCol,lastCol,true,true,true,true);
-		absolute = new AreaPtg(firstRow,lastRow,firstCol,lastCol,false,false,false,false);
-	}
-
-	@Test
-	void testSortTopLeftToBottomRight() {
-	    AreaPtg ptg = new AreaPtg(new AreaReference("A$1:$B5", SpreadsheetVersion.EXCEL2007));
-	    assertEquals("A$1:$B5", ptg.toFormulaString());
-	    ptg.setFirstColumn(3);
-	    assertEquals("D$1:$B5", ptg.toFormulaString(),
-			"Area Ptg should not implicitly re-sort itself (except during construction)");
-	    ptg.sortTopLeftToBottomRight();
-	    assertEquals("$B$1:D5", ptg.toFormulaString(),
-			"Area Ptg should restore itself to top-left to lower-right order when explicitly asked");
-	}
-
-	@Test
-	void testSetColumnsAbsolute() {
-		resetColumns(absolute);
-		validateReference(true, absolute);
-	}
-
-	@Test
-	void testSetColumnsRelative() {
-		resetColumns(relative);
-		validateReference(false, relative);
-	}
-
-	private void validateReference(boolean abs, AreaPtg ref) {
-		String isWrong = " reference is not "+(abs?"absolute":"relative");
-		assertEquals(abs,!ref.isFirstColRelative(),"First column" + isWrong);
-		assertEquals(abs,!ref.isLastColRelative(), "Last column" + isWrong);
-		assertEquals(abs,!ref.isFirstRowRelative(),"First row" + isWrong);
-		assertEquals(abs,!ref.isLastRowRelative(), "Last row" + isWrong);
-	}
-
-
-	private static void resetColumns(AreaPtg aptg) {
-		int fc = aptg.getFirstColumn();
-		int lc = aptg.getLastColumn();
-		aptg.setFirstColumn(fc);
-		aptg.setLastColumn(lc);
-		assertEquals(fc , aptg.getFirstColumn() );
-		assertEquals(lc , aptg.getLastColumn() );
-	}
+    @BeforeEach
+    void setUp() {
+        short firstRow=5;
+        short lastRow=13;
+        short firstCol=7;
+        short lastCol=17;
+        relative = new AreaPtg(firstRow,lastRow,firstCol,lastCol,true,true,true,true);
+        absolute = new AreaPtg(firstRow,lastRow,firstCol,lastCol,false,false,false,false);
+    }
+
+    @Test
+    void testSortTopLeftToBottomRight() {
+        AreaPtg ptg = new AreaPtg(new AreaReference("A$1:$B5", SpreadsheetVersion.EXCEL2007));
+        assertEquals("A$1:$B5", ptg.toFormulaString());
+        ptg.setFirstColumn(3);
+        assertEquals("D$1:$B5", ptg.toFormulaString(),
+            "Area Ptg should not implicitly re-sort itself (except during construction)");
+        ptg.sortTopLeftToBottomRight();
+        assertEquals("$B$1:D5", ptg.toFormulaString(),
+            "Area Ptg should restore itself to top-left to lower-right order when explicitly asked");
+    }
+
+    @Test
+    void testSetColumnsAbsolute() {
+        resetColumns(absolute);
+        validateReference(true, absolute);
+    }
+
+    @Test
+    void testSetColumnsRelative() {
+        resetColumns(relative);
+        validateReference(false, relative);
+    }
 
-	@Test
+    private void validateReference(boolean abs, AreaPtg ref) {
+        String isWrong = " reference is not "+(abs?"absolute":"relative");
+        assertEquals(abs,!ref.isFirstColRelative(),"First column" + isWrong);
+        assertEquals(abs,!ref.isLastColRelative(), "Last column" + isWrong);
+        assertEquals(abs,!ref.isFirstRowRelative(),"First row" + isWrong);
+        assertEquals(abs,!ref.isLastRowRelative(), "Last row" + isWrong);
+    }
+
+
+    private static void resetColumns(AreaPtg aptg) {
+        int fc = aptg.getFirstColumn();
+        int lc = aptg.getLastColumn();
+        aptg.setFirstColumn(fc);
+        aptg.setLastColumn(lc);
+        assertEquals(fc , aptg.getFirstColumn() );
+        assertEquals(lc , aptg.getLastColumn() );
+    }
+
+    @Test
     void testAbsoluteRelativeRefs() {
         AreaPtg sca1 = new AreaPtg(4, 5, 6, 7, true, false, true, false);
         AreaPtg sca2 = new AreaPtg(4, 5, 6, 7, false, true, false, true);
@@ -116,30 +116,30 @@ final class TestAreaPtg {
         );
     }
 
-	@Test
-	void testFormulaParser() {
-		String formula1="SUM($E$5:$E$6)";
-		String expectedFormula1="SUM($F$5:$F$6)";
-		String newFormula1 = shiftAllColumnsBy1(formula1);
-		assertEquals(expectedFormula1, newFormula1, "Absolute references changed");
-
-		String formula2="SUM(E5:E6)";
-		String expectedFormula2="SUM(F5:F6)";
-		String newFormula2 = shiftAllColumnsBy1(formula2);
-		assertEquals(expectedFormula2, newFormula2, "Relative references changed");
-	}
-
-	private static String shiftAllColumnsBy1(String  formula) {
-		int letUsShiftColumn1By1Column=1;
-		Ptg[] ptgs = HSSFFormulaParser.parse(formula, null);
-		for (Ptg ptg : ptgs) {
-			if (ptg instanceof AreaPtg )
-			{
-				AreaPtg aptg = (AreaPtg)ptg;
-				aptg.setFirstColumn((short)(aptg.getFirstColumn()+letUsShiftColumn1By1Column));
-				aptg.setLastColumn((short)(aptg.getLastColumn()+letUsShiftColumn1By1Column));
-			}
-		}
+    @Test
+    void testFormulaParser() {
+        String formula1="SUM($E$5:$E$6)";
+        String expectedFormula1="SUM($F$5:$F$6)";
+        String newFormula1 = shiftAllColumnsBy1(formula1);
+        assertEquals(expectedFormula1, newFormula1, "Absolute references changed");
+
+        String formula2="SUM(E5:E6)";
+        String expectedFormula2="SUM(F5:F6)";
+        String newFormula2 = shiftAllColumnsBy1(formula2);
+        assertEquals(expectedFormula2, newFormula2, "Relative references changed");
+    }
+
+    private static String shiftAllColumnsBy1(String  formula) {
+        int letUsShiftColumn1By1Column=1;
+        Ptg[] ptgs = HSSFFormulaParser.parse(formula, null);
+        for (Ptg ptg : ptgs) {
+            if (ptg instanceof AreaPtg )
+            {
+                AreaPtg aptg = (AreaPtg)ptg;
+                aptg.setFirstColumn((short)(aptg.getFirstColumn()+letUsShiftColumn1By1Column));
+                aptg.setLastColumn((short)(aptg.getLastColumn()+letUsShiftColumn1By1Column));
+            }
+        }
         return HSSFFormulaParser.toFormulaString(null, ptgs);
-	}
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestArrayPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestArrayPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestArrayPtg.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestArrayPtg.java Sat May 22 20:56:44 2021
@@ -33,120 +33,120 @@ import org.junit.jupiter.api.Test;
  */
 final class TestArrayPtg {
 
-	private static final byte[] ENCODED_PTG_DATA = {
-		0x40,
-		0, 0, 0, 0, 0, 0, 0,
-	};
-	private static final byte[] ENCODED_CONSTANT_DATA = {
-		2,    // 3 columns
-		1, 0, // 2 rows
-		4, 1, 0, 0, 0, 0, 0, 0, 0, // TRUE
-		2, 4, 0, 0, 65, 66, 67, 68, // "ABCD"
-		2, 1, 0, 0, 69, // "E"
-		1, 0, 0, 0, 0, 0, 0, 0, 0, // 0
-		4, 0, 0, 0, 0, 0, 0, 0, 0, // FALSE
-		2, 2, 0, 0, 70, 71, // "FG"
-	};
-
-	private static ArrayPtg create(byte[] initialData, byte[] constantData) {
-		ArrayInitialPtg ptgInit = new ArrayInitialPtg(TestcaseRecordInputStream.createLittleEndian(initialData));
-		return ptgInit.finishReading(TestcaseRecordInputStream.createLittleEndian(constantData));
-	}
-
-	/**
-	 * Lots of problems with ArrayPtg's decoding and encoding of the element value data
-	 */
-	@Test
-	void testReadWriteTokenValueBytes() {
-		ArrayPtg ptg = create(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);
-		assertEquals(3, ptg.getColumnCount());
-		assertEquals(2, ptg.getRowCount());
-		Object[][] values = ptg.getTokenArrayValues();
-		assertEquals(2, values.length);
-
-
-		assertEquals(Boolean.TRUE, values[0][0]);
-		assertEquals("ABCD", values[0][1]);
-		assertEquals(0d, values[1][0]);
-		assertEquals(Boolean.FALSE, values[1][1]);
-		assertEquals("FG", values[1][2]);
-
-		byte[] outBuf = new byte[ENCODED_CONSTANT_DATA.length];
-		ptg.writeTokenValueBytes(new LittleEndianByteArrayOutputStream(outBuf, 0));
-
-		assertNotEquals(4, outBuf[0], "Identified bug 42564b");
-		assertArrayEquals(ENCODED_CONSTANT_DATA, outBuf);
-	}
-
-
-	/**
-	 * Excel stores array elements column by column.  This test makes sure POI does the same.
-	 */
-	@Test
-	void testElementOrdering() {
-		ArrayPtg ptg = create(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);
-		assertEquals(3, ptg.getColumnCount());
-		assertEquals(2, ptg.getRowCount());
-
-		assertEquals(0, ptg.getValueIndex(0, 0));
-		assertEquals(1, ptg.getValueIndex(1, 0));
-		assertEquals(2, ptg.getValueIndex(2, 0));
-		assertEquals(3, ptg.getValueIndex(0, 1));
-		assertEquals(4, ptg.getValueIndex(1, 1));
-		assertEquals(5, ptg.getValueIndex(2, 1));
-	}
-
-	/**
-	 * Test for a bug which was temporarily introduced by the fix for bug 42564.
-	 * A spreadsheet was added to make the ordering clearer.
-	 */
-	@Test
-	void testElementOrderingInSpreadsheet() {
-		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex42564-elementOrder.xls");
-
-		// The formula has an array with 3 rows and 5 columns
-		String formula = wb.getSheetAt(0).getRow(0).getCell(0).getCellFormula();
-
-		assertNotEquals("Identified bug 42564 b", "SUM({1,6,11;2,7,12;3,8,13;4,9,14;5,10,15})", formula);
-		assertEquals("SUM({1,2,3,4,5;6,7,8,9,10;11,12,13,14,15})", formula);
-	}
-
-	@Test
-	void testToFormulaString() {
-		ArrayPtg ptg = create(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);
-		// bug 45380 - Unexpected constant class (java.lang.Boolean)
-		String actualFormula = ptg.toFormulaString();
-		assertEquals("{TRUE,\"ABCD\",\"E\";0,FALSE,\"FG\"}", actualFormula);
-	}
-
-	/**
-	 * worth checking since AttrPtg.sid=0x20 and Ptg.CLASS_* = (0x00, 0x20, and 0x40)
-	 */
-	@Test
-	void testOperandClassDecoding() {
-		confirmOperandClassDecoding(Ptg.CLASS_REF);
-		confirmOperandClassDecoding(Ptg.CLASS_VALUE);
-		confirmOperandClassDecoding(Ptg.CLASS_ARRAY);
-	}
-
-	private static void confirmOperandClassDecoding(byte operandClass) {
-		byte[] fullData = concat(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);
-
-		// Force encoded operand class for tArray
-		fullData[0] = (byte) (ArrayPtg.sid + operandClass);
-
-		LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(fullData);
-
-		Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in);
-		assertEquals(1, ptgs.length);
-		ArrayPtg aPtg = (ArrayPtg) ptgs[0];
-		assertEquals(operandClass, aPtg.getPtgClass());
-	}
-
-	private static byte[] concat(byte[] a, byte[] b) {
-		byte[] result = new byte[a.length + b.length];
-		System.arraycopy(a, 0, result, 0, a.length);
-		System.arraycopy(b, 0, result, a.length, b.length);
-		return result;
-	}
+    private static final byte[] ENCODED_PTG_DATA = {
+        0x40,
+        0, 0, 0, 0, 0, 0, 0,
+    };
+    private static final byte[] ENCODED_CONSTANT_DATA = {
+        2,    // 3 columns
+        1, 0, // 2 rows
+        4, 1, 0, 0, 0, 0, 0, 0, 0, // TRUE
+        2, 4, 0, 0, 65, 66, 67, 68, // "ABCD"
+        2, 1, 0, 0, 69, // "E"
+        1, 0, 0, 0, 0, 0, 0, 0, 0, // 0
+        4, 0, 0, 0, 0, 0, 0, 0, 0, // FALSE
+        2, 2, 0, 0, 70, 71, // "FG"
+    };
+
+    private static ArrayPtg create(byte[] initialData, byte[] constantData) {
+        ArrayInitialPtg ptgInit = new ArrayInitialPtg(TestcaseRecordInputStream.createLittleEndian(initialData));
+        return ptgInit.finishReading(TestcaseRecordInputStream.createLittleEndian(constantData));
+    }
+
+    /**
+     * Lots of problems with ArrayPtg's decoding and encoding of the element value data
+     */
+    @Test
+    void testReadWriteTokenValueBytes() {
+        ArrayPtg ptg = create(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);
+        assertEquals(3, ptg.getColumnCount());
+        assertEquals(2, ptg.getRowCount());
+        Object[][] values = ptg.getTokenArrayValues();
+        assertEquals(2, values.length);
+
+
+        assertEquals(Boolean.TRUE, values[0][0]);
+        assertEquals("ABCD", values[0][1]);
+        assertEquals(0d, values[1][0]);
+        assertEquals(Boolean.FALSE, values[1][1]);
+        assertEquals("FG", values[1][2]);
+
+        byte[] outBuf = new byte[ENCODED_CONSTANT_DATA.length];
+        ptg.writeTokenValueBytes(new LittleEndianByteArrayOutputStream(outBuf, 0));
+
+        assertNotEquals(4, outBuf[0], "Identified bug 42564b");
+        assertArrayEquals(ENCODED_CONSTANT_DATA, outBuf);
+    }
+
+
+    /**
+     * Excel stores array elements column by column.  This test makes sure POI does the same.
+     */
+    @Test
+    void testElementOrdering() {
+        ArrayPtg ptg = create(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);
+        assertEquals(3, ptg.getColumnCount());
+        assertEquals(2, ptg.getRowCount());
+
+        assertEquals(0, ptg.getValueIndex(0, 0));
+        assertEquals(1, ptg.getValueIndex(1, 0));
+        assertEquals(2, ptg.getValueIndex(2, 0));
+        assertEquals(3, ptg.getValueIndex(0, 1));
+        assertEquals(4, ptg.getValueIndex(1, 1));
+        assertEquals(5, ptg.getValueIndex(2, 1));
+    }
+
+    /**
+     * Test for a bug which was temporarily introduced by the fix for bug 42564.
+     * A spreadsheet was added to make the ordering clearer.
+     */
+    @Test
+    void testElementOrderingInSpreadsheet() {
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex42564-elementOrder.xls");
+
+        // The formula has an array with 3 rows and 5 columns
+        String formula = wb.getSheetAt(0).getRow(0).getCell(0).getCellFormula();
+
+        assertNotEquals("Identified bug 42564 b", "SUM({1,6,11;2,7,12;3,8,13;4,9,14;5,10,15})", formula);
+        assertEquals("SUM({1,2,3,4,5;6,7,8,9,10;11,12,13,14,15})", formula);
+    }
+
+    @Test
+    void testToFormulaString() {
+        ArrayPtg ptg = create(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);
+        // bug 45380 - Unexpected constant class (java.lang.Boolean)
+        String actualFormula = ptg.toFormulaString();
+        assertEquals("{TRUE,\"ABCD\",\"E\";0,FALSE,\"FG\"}", actualFormula);
+    }
+
+    /**
+     * worth checking since AttrPtg.sid=0x20 and Ptg.CLASS_* = (0x00, 0x20, and 0x40)
+     */
+    @Test
+    void testOperandClassDecoding() {
+        confirmOperandClassDecoding(Ptg.CLASS_REF);
+        confirmOperandClassDecoding(Ptg.CLASS_VALUE);
+        confirmOperandClassDecoding(Ptg.CLASS_ARRAY);
+    }
+
+    private static void confirmOperandClassDecoding(byte operandClass) {
+        byte[] fullData = concat(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);
+
+        // Force encoded operand class for tArray
+        fullData[0] = (byte) (ArrayPtg.sid + operandClass);
+
+        LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(fullData);
+
+        Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in);
+        assertEquals(1, ptgs.length);
+        ArrayPtg aPtg = (ArrayPtg) ptgs[0];
+        assertEquals(operandClass, aPtg.getPtgClass());
+    }
+
+    private static byte[] concat(byte[] a, byte[] b) {
+        byte[] result = new byte[a.length + b.length];
+        System.arraycopy(a, 0, result, 0, a.length);
+        System.arraycopy(b, 0, result, a.length, b.length);
+        return result;
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestAttrPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestAttrPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestAttrPtg.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestAttrPtg.java Sat May 22 20:56:44 2021
@@ -29,17 +29,17 @@ import org.junit.jupiter.api.Test;
  */
 final class TestAttrPtg extends BaseTestPtg {
 
-	/**
-	 * Fix for bug visible around svn r706772.
-	 */
-	@Test
-	void testReserializeAttrChoose() {
-		byte[] data = HexRead.readFromString("19, 04, 03, 00, 08, 00, 11, 00, 1A, 00, 23, 00");
-		LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(data);
-		Ptg[] ptgs = Ptg.readTokens(data.length, in);
-		byte[] data2 = new byte[data.length];
-		// ArrayIndexOutOfBoundsException -> incorrect re-serialization of tAttrChoose
-		Ptg.serializePtgs(ptgs, data2, 0);
-		assertArrayEquals(data, data2);
-	}
+    /**
+     * Fix for bug visible around svn r706772.
+     */
+    @Test
+    void testReserializeAttrChoose() {
+        byte[] data = HexRead.readFromString("19, 04, 03, 00, 08, 00, 11, 00, 1A, 00, 23, 00");
+        LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(data);
+        Ptg[] ptgs = Ptg.readTokens(data.length, in);
+        byte[] data2 = new byte[data.length];
+        // ArrayIndexOutOfBoundsException -> incorrect re-serialization of tAttrChoose
+        Ptg.serializePtgs(ptgs, data2, 0);
+        assertArrayEquals(data, data2);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestExternalFunctionFormulas.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestExternalFunctionFormulas.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestExternalFunctionFormulas.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestExternalFunctionFormulas.java Sat May 22 20:56:44 2021
@@ -33,62 +33,62 @@ import org.junit.jupiter.api.Test;
  */
 final class TestExternalFunctionFormulas {
 
-	/**
-	 * tests {@code NameXPtg.toFormulaString(Workbook)} and logic in Workbook below that
-	 */
+    /**
+     * tests {@code NameXPtg.toFormulaString(Workbook)} and logic in Workbook below that
+     */
     @Test
-	void testReadFormulaContainingExternalFunction() throws Exception {
-		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("externalFunctionExample.xls");
+    void testReadFormulaContainingExternalFunction() throws Exception {
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("externalFunctionExample.xls");
 
-		String expectedFormula = "YEARFRAC(B1,C1)";
-		HSSFSheet sht = wb.getSheetAt(0);
-		String cellFormula = sht.getRow(0).getCell(0).getCellFormula();
-		assertEquals(expectedFormula, cellFormula);
+        String expectedFormula = "YEARFRAC(B1,C1)";
+        HSSFSheet sht = wb.getSheetAt(0);
+        String cellFormula = sht.getRow(0).getCell(0).getCellFormula();
+        assertEquals(expectedFormula, cellFormula);
 
-		wb.close();
-	}
+        wb.close();
+    }
 
     @Test
     void testParse() throws Exception {
-		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("externalFunctionExample.xls");
-		Ptg[] ptgs = HSSFFormulaParser.parse("YEARFRAC(B1,C1)", wb);
-		assertEquals(4, ptgs.length);
-		assertEquals(NameXPtg.class, ptgs[0].getClass());
-
-		wb.getSheetAt(0).getRow(0).createCell(6).setCellFormula("YEARFRAC(C1,B1)");
-//		if (false) {
-//			// In case you fancy checking in excel
-//			try {
-//				File tempFile = TempFile.createTempFile("testExtFunc", ".xls");
-//				FileOutputStream fout = new FileOutputStream(tempFile);
-//				wb.write(fout);
-//				fout.close();
-//				System.out.println("check out " + tempFile.getAbsolutePath());
-//			} catch (IOException e) {
-//				throw new RuntimeException(e);
-//			}
-//		}
-		wb.close();
-	}
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("externalFunctionExample.xls");
+        Ptg[] ptgs = HSSFFormulaParser.parse("YEARFRAC(B1,C1)", wb);
+        assertEquals(4, ptgs.length);
+        assertEquals(NameXPtg.class, ptgs[0].getClass());
+
+        wb.getSheetAt(0).getRow(0).createCell(6).setCellFormula("YEARFRAC(C1,B1)");
+//      if (false) {
+//          // In case you fancy checking in excel
+//          try {
+//              File tempFile = TempFile.createTempFile("testExtFunc", ".xls");
+//              FileOutputStream fout = new FileOutputStream(tempFile);
+//              wb.write(fout);
+//              fout.close();
+//              System.out.println("check out " + tempFile.getAbsolutePath());
+//          } catch (IOException e) {
+//              throw new RuntimeException(e);
+//          }
+//      }
+        wb.close();
+    }
 
     @Test
-	void testEvaluate() throws Exception {
-		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("externalFunctionExample.xls");
-		HSSFSheet sheet = wb.getSheetAt(0);
-		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
-		confirmCellEval(sheet, 0, 0, fe, "YEARFRAC(B1,C1)", 29.0/90.0);
-		confirmCellEval(sheet, 1, 0, fe, "YEARFRAC(B2,C2)", 0.0);
-		confirmCellEval(sheet, 2, 0, fe, "YEARFRAC(B3,C3,D3)", 0.0);
-		confirmCellEval(sheet, 3, 0, fe, "IF(ISEVEN(3),1.2,1.6)", 1.6);
-		confirmCellEval(sheet, 4, 0, fe, "IF(ISODD(3),1.2,1.6)", 1.2);
-		wb.close();
-	}
-
-	private static void confirmCellEval(HSSFSheet sheet, int rowIx, int colIx,
-			HSSFFormulaEvaluator fe, String expectedFormula, double expectedResult) {
-		HSSFCell cell = sheet.getRow(rowIx).getCell(colIx);
-		assertEquals(expectedFormula, cell.getCellFormula());
-		CellValue cv = fe.evaluate(cell);
-		assertEquals(expectedResult, cv.getNumberValue(), 0.0);
-	}
+    void testEvaluate() throws Exception {
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("externalFunctionExample.xls");
+        HSSFSheet sheet = wb.getSheetAt(0);
+        HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
+        confirmCellEval(sheet, 0, 0, fe, "YEARFRAC(B1,C1)", 29.0/90.0);
+        confirmCellEval(sheet, 1, 0, fe, "YEARFRAC(B2,C2)", 0.0);
+        confirmCellEval(sheet, 2, 0, fe, "YEARFRAC(B3,C3,D3)", 0.0);
+        confirmCellEval(sheet, 3, 0, fe, "IF(ISEVEN(3),1.2,1.6)", 1.6);
+        confirmCellEval(sheet, 4, 0, fe, "IF(ISODD(3),1.2,1.6)", 1.2);
+        wb.close();
+    }
+
+    private static void confirmCellEval(HSSFSheet sheet, int rowIx, int colIx,
+            HSSFFormulaEvaluator fe, String expectedFormula, double expectedResult) {
+        HSSFCell cell = sheet.getRow(rowIx).getCell(colIx);
+        assertEquals(expectedFormula, cell.getCellFormula());
+        CellValue cv = fe.evaluate(cell);
+        assertEquals(expectedResult, cv.getNumberValue(), 0.0);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestExternalNameReference.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestExternalNameReference.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestExternalNameReference.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestExternalNameReference.java Sat May 22 20:56:44 2021
@@ -33,97 +33,97 @@ import org.junit.jupiter.api.Test;
  * Tests for proper calculation of named ranges from external workbooks.
  */
 final class TestExternalNameReference {
-	double MARKUP_COST_1 = 1.8d;
-	double MARKUP_COST_2 = 1.5d;
-	double PART_COST = 12.3d;
-	double NEW_QUANT = 7.0d;
-	double NEW_PART_COST = 15.3d;
-	/**
-	 * tests {@code NameXPtg for external cell reference by name} and logic in Workbook below that
-	 */
-	@Test
-	void testReadCalcSheet() {
-		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("XRefCalc.xls");
-		HSSFName name = wb.getName("QUANT");
-		assertNotNull(name);
-		assertEquals("Sheet1!$A$2", name.getRefersToFormula());
-		name = wb.getName("PART");
-		assertNotNull(name);
-		assertEquals("Sheet1!$B$2", name.getRefersToFormula());
-		assertEquals("x123",wb.getSheet("Sheet1").getRow(1).getCell(1).getStringCellValue());
-		name = wb.getName("UNITCOST");
-		assertNotNull(name);
-		assertEquals("Sheet1!$C$2", name.getRefersToFormula());
-		name = wb.getName("UNITCOST");
-		assertNotNull(name);
-		CellReference cellRef = new CellReference(name.getRefersToFormula());
-		HSSFCell cell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
-		assertEquals("VLOOKUP(PART,COSTS,2,FALSE)",cell.getCellFormula());
-		name = wb.getName("COST");
-		assertNotNull(name);
-		assertEquals("Sheet1!$D$2", name.getRefersToFormula());
-		name = wb.getName("COST");
-		assertNotNull(name);
-		cellRef = new CellReference(name.getRefersToFormula());
-		cell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
-		assertEquals("UNITCOST*Quant",cell.getCellFormula());
-		name = wb.getName("TOTALCOST");
-		assertNotNull(name);
-		assertEquals("Sheet1!$E$2", name.getRefersToFormula());
-		name = wb.getName("TOTALCOST");
-		assertNotNull(name);
-		cellRef = new CellReference(name.getRefersToFormula());
-		cell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
-		assertEquals("Cost*Markup_Cost",cell.getCellFormula());
-	}
+    double MARKUP_COST_1 = 1.8d;
+    double MARKUP_COST_2 = 1.5d;
+    double PART_COST = 12.3d;
+    double NEW_QUANT = 7.0d;
+    double NEW_PART_COST = 15.3d;
+    /**
+     * tests {@code NameXPtg for external cell reference by name} and logic in Workbook below that
+     */
+    @Test
+    void testReadCalcSheet() {
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("XRefCalc.xls");
+        HSSFName name = wb.getName("QUANT");
+        assertNotNull(name);
+        assertEquals("Sheet1!$A$2", name.getRefersToFormula());
+        name = wb.getName("PART");
+        assertNotNull(name);
+        assertEquals("Sheet1!$B$2", name.getRefersToFormula());
+        assertEquals("x123",wb.getSheet("Sheet1").getRow(1).getCell(1).getStringCellValue());
+        name = wb.getName("UNITCOST");
+        assertNotNull(name);
+        assertEquals("Sheet1!$C$2", name.getRefersToFormula());
+        name = wb.getName("UNITCOST");
+        assertNotNull(name);
+        CellReference cellRef = new CellReference(name.getRefersToFormula());
+        HSSFCell cell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
+        assertEquals("VLOOKUP(PART,COSTS,2,FALSE)",cell.getCellFormula());
+        name = wb.getName("COST");
+        assertNotNull(name);
+        assertEquals("Sheet1!$D$2", name.getRefersToFormula());
+        name = wb.getName("COST");
+        assertNotNull(name);
+        cellRef = new CellReference(name.getRefersToFormula());
+        cell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
+        assertEquals("UNITCOST*Quant",cell.getCellFormula());
+        name = wb.getName("TOTALCOST");
+        assertNotNull(name);
+        assertEquals("Sheet1!$E$2", name.getRefersToFormula());
+        name = wb.getName("TOTALCOST");
+        assertNotNull(name);
+        cellRef = new CellReference(name.getRefersToFormula());
+        cell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
+        assertEquals("Cost*Markup_Cost",cell.getCellFormula());
+    }
 
-	@Test
-	void testReadReferencedSheet() {
-		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("XRefCalcData.xls");
-		HSSFName name = wb.getName("COSTS");
-		assertNotNull(name);
-		assertEquals("CostSheet!$A$2:$B$3", name.getRefersToFormula());
-		assertEquals("x123",wb.getSheet("CostSheet").getRow(1).getCell(0).getStringCellValue());
-		assertEquals(PART_COST,wb.getSheet("CostSheet").getRow(1).getCell(1).getNumericCellValue(), 0);
-		name = wb.getName("Markup_Cost");
-		assertNotNull(name);
-		assertEquals("MarkupSheet!$B$1", name.getRefersToFormula());
-		assertEquals(MARKUP_COST_1,wb.getSheet("MarkupSheet").getRow(0).getCell(1).getNumericCellValue(), 0);
-	}
+    @Test
+    void testReadReferencedSheet() {
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("XRefCalcData.xls");
+        HSSFName name = wb.getName("COSTS");
+        assertNotNull(name);
+        assertEquals("CostSheet!$A$2:$B$3", name.getRefersToFormula());
+        assertEquals("x123",wb.getSheet("CostSheet").getRow(1).getCell(0).getStringCellValue());
+        assertEquals(PART_COST,wb.getSheet("CostSheet").getRow(1).getCell(1).getNumericCellValue(), 0);
+        name = wb.getName("Markup_Cost");
+        assertNotNull(name);
+        assertEquals("MarkupSheet!$B$1", name.getRefersToFormula());
+        assertEquals(MARKUP_COST_1,wb.getSheet("MarkupSheet").getRow(0).getCell(1).getNumericCellValue(), 0);
+    }
 
-	@Test
-	void testEvaluate() {
-		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("XRefCalc.xls");
-		HSSFWorkbook wb2 = HSSFTestDataSamples.openSampleWorkbook("XRefCalcData.xls");
-		HSSFName name = wb.getName("QUANT");
-		assertNotNull(name);
-		CellReference cellRef = new CellReference(name.getRefersToFormula());
-		HSSFCell cell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
-		cell.setCellValue(NEW_QUANT);
-		cell = wb2.getSheet("CostSheet").getRow(1).getCell(1);
-		cell.setCellValue(NEW_PART_COST);
-		HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
-		HSSFFormulaEvaluator evaluatorCost = new HSSFFormulaEvaluator(wb2);
-		String[] bookNames = { "XRefCalc.xls", "XRefCalcData.xls" };
-		HSSFFormulaEvaluator[] evaluators = { evaluator, evaluatorCost, };
-		HSSFFormulaEvaluator.setupEnvironment(bookNames, evaluators);
-		name = wb.getName("UNITCOST");
-		assertNotNull(name);
-		cellRef = new CellReference(name.getRefersToFormula());
-		HSSFCell uccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
-		name = wb.getName("COST");
-		assertNotNull(name);
-		cellRef = new CellReference(name.getRefersToFormula());
-		HSSFCell ccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
-		name = wb.getName("TOTALCOST");
-		assertNotNull(name);
-		cellRef = new CellReference(name.getRefersToFormula());
-		HSSFCell tccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
-		evaluator.evaluateFormulaCell(uccell);
-		evaluator.evaluateFormulaCell(ccell);
-		evaluator.evaluateFormulaCell(tccell);
-		assertEquals(NEW_PART_COST, uccell.getNumericCellValue(), 0);
-		assertEquals(NEW_PART_COST*NEW_QUANT, ccell.getNumericCellValue(), 0);
-		assertEquals(NEW_PART_COST*NEW_QUANT*MARKUP_COST_2, tccell.getNumericCellValue(), 0);
-	}
+    @Test
+    void testEvaluate() {
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("XRefCalc.xls");
+        HSSFWorkbook wb2 = HSSFTestDataSamples.openSampleWorkbook("XRefCalcData.xls");
+        HSSFName name = wb.getName("QUANT");
+        assertNotNull(name);
+        CellReference cellRef = new CellReference(name.getRefersToFormula());
+        HSSFCell cell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
+        cell.setCellValue(NEW_QUANT);
+        cell = wb2.getSheet("CostSheet").getRow(1).getCell(1);
+        cell.setCellValue(NEW_PART_COST);
+        HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
+        HSSFFormulaEvaluator evaluatorCost = new HSSFFormulaEvaluator(wb2);
+        String[] bookNames = { "XRefCalc.xls", "XRefCalcData.xls" };
+        HSSFFormulaEvaluator[] evaluators = { evaluator, evaluatorCost, };
+        HSSFFormulaEvaluator.setupEnvironment(bookNames, evaluators);
+        name = wb.getName("UNITCOST");
+        assertNotNull(name);
+        cellRef = new CellReference(name.getRefersToFormula());
+        HSSFCell uccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
+        name = wb.getName("COST");
+        assertNotNull(name);
+        cellRef = new CellReference(name.getRefersToFormula());
+        HSSFCell ccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
+        name = wb.getName("TOTALCOST");
+        assertNotNull(name);
+        cellRef = new CellReference(name.getRefersToFormula());
+        HSSFCell tccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell(cellRef.getCol());
+        evaluator.evaluateFormulaCell(uccell);
+        evaluator.evaluateFormulaCell(ccell);
+        evaluator.evaluateFormulaCell(tccell);
+        assertEquals(NEW_PART_COST, uccell.getNumericCellValue(), 0);
+        assertEquals(NEW_PART_COST*NEW_QUANT, ccell.getNumericCellValue(), 0);
+        assertEquals(NEW_PART_COST*NEW_QUANT*MARKUP_COST_2, tccell.getNumericCellValue(), 0);
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestFuncPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestFuncPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestFuncPtg.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestFuncPtg.java Sat May 22 20:56:44 2021
@@ -29,7 +29,7 @@ final class TestFuncPtg {
 
     @Test
     void testRead() {
-    	// This function index represents the LEN() function
+        // This function index represents the LEN() function
         byte[] fakeData = { 0x20, 0x00,};
 
         FuncPtg ptg = FuncPtg.create(TestcaseRecordInputStream.createLittleEndian(fakeData) );

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestFuncVarPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestFuncVarPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestFuncVarPtg.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestFuncVarPtg.java Sat May 22 20:56:44 2021
@@ -26,31 +26,31 @@ import org.junit.jupiter.api.Test;
 
 final class TestFuncVarPtg {
 
-	/**
-	 * The first fix for bugzilla 44675 broke the encoding of SUM formulas (and probably others).
-	 * The operand classes of the parameters to SUM() should be coerced to 'reference' not 'value'.
-	 * In the case of SUM, Excel evaluates the formula to '#VALUE!' if a parameter operand class is
-	 * wrong.  In other cases Excel seems to tolerate bad operand classes.<p>
-	 *
-	 * This functionality is related to the setParameterRVA() methods of {@code FormulaParser}
-	 */
-	@Test
-	void testOperandClass() {
-		HSSFWorkbook book = new HSSFWorkbook();
-		Ptg[] ptgs = HSSFFormulaParser.parse("sum(A1:A2)", book);
-		assertEquals(2, ptgs.length);
-		assertEquals(AreaPtg.class, ptgs[0].getClass());
+    /**
+     * The first fix for bugzilla 44675 broke the encoding of SUM formulas (and probably others).
+     * The operand classes of the parameters to SUM() should be coerced to 'reference' not 'value'.
+     * In the case of SUM, Excel evaluates the formula to '#VALUE!' if a parameter operand class is
+     * wrong.  In other cases Excel seems to tolerate bad operand classes.<p>
+     *
+     * This functionality is related to the setParameterRVA() methods of {@code FormulaParser}
+     */
+    @Test
+    void testOperandClass() {
+        HSSFWorkbook book = new HSSFWorkbook();
+        Ptg[] ptgs = HSSFFormulaParser.parse("sum(A1:A2)", book);
+        assertEquals(2, ptgs.length);
+        assertEquals(AreaPtg.class, ptgs[0].getClass());
 
-		switch(ptgs[0].getPtgClass()) {
-			case Ptg.CLASS_REF:
-				// correct behaviour
-				break;
-			case Ptg.CLASS_VALUE:
-				fail("Identified bug 44675b");
-				break;
-			default:
-				fail("Unexpected operand class");
-				break;
-		}
-	}
+        switch(ptgs[0].getPtgClass()) {
+            case Ptg.CLASS_REF:
+                // correct behaviour
+                break;
+            case Ptg.CLASS_VALUE:
+                fail("Identified bug 44675b");
+                break;
+            default:
+                fail("Unexpected operand class");
+                break;
+        }
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java Sat May 22 20:56:44 2021
@@ -29,20 +29,20 @@ import org.junit.jupiter.api.Test;
  * Tests for Ref3DPtg
  */
 final class TestRef3DPtg extends BaseTestPtg {
-	@Test
-	void testToFormulaString() throws IOException {
+    @Test
+    void testToFormulaString() throws IOException {
 
-		Ref3DPtg target = new Ref3DPtg("A1", (short)0);
+        Ref3DPtg target = new Ref3DPtg("A1", (short)0);
 
-		try (HSSFWorkbook wb = createWorkbookWithSheet("my sheet")) {
-			HSSFEvaluationWorkbook book = HSSFEvaluationWorkbook.create(wb);
-			assertEquals("'my sheet'!A1", target.toFormulaString(book));
+        try (HSSFWorkbook wb = createWorkbookWithSheet("my sheet")) {
+            HSSFEvaluationWorkbook book = HSSFEvaluationWorkbook.create(wb);
+            assertEquals("'my sheet'!A1", target.toFormulaString(book));
 
-			wb.setSheetName(0, "ProfitAndLoss");
-			assertEquals("ProfitAndLoss!A1", target.toFormulaString(book));
+            wb.setSheetName(0, "ProfitAndLoss");
+            assertEquals("ProfitAndLoss!A1", target.toFormulaString(book));
 
-			wb.setSheetName(0, "profit+loss");
-			assertEquals("'profit+loss'!A1", target.toFormulaString(book));
-		}
-	}
+            wb.setSheetName(0, "profit+loss");
+            assertEquals("'profit+loss'!A1", target.toFormulaString(book));
+        }
+    }
 }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestReferencePtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestReferencePtg.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestReferencePtg.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/ptg/TestReferencePtg.java Sat May 22 20:56:44 2021
@@ -77,12 +77,12 @@ final class TestReferencePtg {
     }
 
     private static final byte[] tRefN_data = {
-    	0x2C, 33, 44, 55, 66,
+        0x2C, 33, 44, 55, 66,
     };
 
     @Test
     void testReadWrite_tRefN_bug45091() {
-    	LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(tRefN_data);
+        LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(tRefN_data);
         Ptg[] ptgs = Ptg.readTokens(tRefN_data.length, in);
         byte[] outData = new byte[5];
         Ptg.serializePtgs(ptgs, outData, 0);

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/udf/TestUDFFinder.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/udf/TestUDFFinder.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/udf/TestUDFFinder.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/udf/TestUDFFinder.java Sat May 22 20:56:44 2021
@@ -6,7 +6,7 @@
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
 
-	   http://www.apache.org/licenses/LICENSE-2.0
+       http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestDataValidation.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestDataValidation.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestDataValidation.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestDataValidation.java Sat May 22 20:56:44 2021
@@ -475,8 +475,8 @@ public abstract class BaseTestDataValida
             // Custom Validation type
             addCustomValidations(wf1);
             try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1)) {
-				Sheet sh = wb2.getSheet("Numbers");
-				assertEquals(16, sh.getDataValidations().size());
+                Sheet sh = wb2.getSheet("Numbers");
+                assertEquals(16, sh.getDataValidations().size());
             }
 
         }

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java Sat May 22 20:56:44 2021
@@ -37,16 +37,16 @@ import org.junit.jupiter.api.Test;
  */
 public abstract class BaseTestFormulaEvaluator {
 
-	protected final ITestDataProvider _testDataProvider;
+    protected final ITestDataProvider _testDataProvider;
 
-	/**
-	 * @param testDataProvider an object that provides test data in  /  specific way
-	 */
-	protected BaseTestFormulaEvaluator(ITestDataProvider testDataProvider) {
-		_testDataProvider = testDataProvider;
-	}
+    /**
+     * @param testDataProvider an object that provides test data in  /  specific way
+     */
+    protected BaseTestFormulaEvaluator(ITestDataProvider testDataProvider) {
+        _testDataProvider = testDataProvider;
+    }
 
-	@Test
+    @Test
     void testSimpleArithmetic() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
         Sheet s = wb.createSheet();
@@ -71,8 +71,8 @@ public abstract class BaseTestFormulaEva
         wb.close();
     }
 
-	@Test
-	void testSumCount() throws IOException {
+    @Test
+    void testSumCount() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
         Sheet s = wb.createSheet();
         Row r = s.createRow(0);
@@ -117,7 +117,7 @@ public abstract class BaseTestFormulaEva
     }
 
     @Test
-	void testSharedFormulas() throws IOException {
+    void testSharedFormulas() throws IOException {
         String fileName = "shared_formulas.xls" + (getClass().getName().contains("xssf") ? "x" : "");
         try (Workbook wb = _testDataProvider.openSampleWorkbook(fileName)) {
 
@@ -147,7 +147,7 @@ public abstract class BaseTestFormulaEva
     /**
      * Test creation / evaluation of formulas with sheet-level names
      */
-	@Test
+    @Test
     void testSheetLevelFormulas() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
 
@@ -183,7 +183,7 @@ public abstract class BaseTestFormulaEva
         wb.close();
     }
 
-	@Test
+    @Test
     void testFullColumnRefs() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
         Sheet sheet = wb.createSheet("Sheet1");
@@ -217,7 +217,7 @@ public abstract class BaseTestFormulaEva
         wb.close();
     }
 
-	@Test
+    @Test
     void testRepeatedEvaluation() throws IOException {
        Workbook wb = _testDataProvider.createWorkbook();
        FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java Sat May 22 20:56:44 2021
@@ -31,33 +31,33 @@ import org.junit.jupiter.api.Test;
 
 public abstract class BaseTestSheetHiding {
 
-	protected final ITestDataProvider _testDataProvider;
+    protected final ITestDataProvider _testDataProvider;
     protected Workbook wbH;
     protected Workbook wbU;
 
     private final String _file1, _file2;
 
     /**
-	 * @param testDataProvider an object that provides test data in HSSF /  specific way
-	 */
-	protected BaseTestSheetHiding(ITestDataProvider testDataProvider,
+     * @param testDataProvider an object that provides test data in HSSF /  specific way
+     */
+    protected BaseTestSheetHiding(ITestDataProvider testDataProvider,
                                   String file1, String file2) {
-		_testDataProvider = testDataProvider;
+        _testDataProvider = testDataProvider;
         _file1 = file1;
         _file2 = file2;
     }
 
-	@BeforeEach
+    @BeforeEach
     void setUp() {
         wbH = _testDataProvider.openSampleWorkbook(_file1);
         wbU = _testDataProvider.openSampleWorkbook(_file2);
     }
 
-	@AfterEach
-	void teadDown() throws IOException {
-	    wbH.close();
-	    wbU.close();
-	}
+    @AfterEach
+    void teadDown() throws IOException {
+        wbH.close();
+        wbU.close();
+    }
 
     @Test
     public final void testSheetVisibility() throws IOException {
@@ -98,7 +98,7 @@ public abstract class BaseTestSheetHidin
      *  with the right text on them, no matter what
      *  the hidden flags are
      */
-	@Test
+    @Test
     void testTextSheets() {
         // Both should have two sheets
         assertEquals(2, wbH.getNumberOfSheets());
@@ -127,7 +127,7 @@ public abstract class BaseTestSheetHidin
      * Check that we can get and set the hidden flags
      *  as expected
      */
-	@Test
+    @Test
     void testHideUnHideFlags() {
         assertTrue(wbH.isSheetHidden(0));
         assertFalse(wbH.isSheetHidden(1));
@@ -139,7 +139,7 @@ public abstract class BaseTestSheetHidin
      * Turn the sheet with none hidden into the one with
      *  one hidden
      */
-	@Test
+    @Test
     void testHide() throws IOException {
         wbU.setSheetHidden(0, true);
         assertTrue(wbU.isSheetHidden(0));
@@ -154,7 +154,7 @@ public abstract class BaseTestSheetHidin
      * Turn the sheet with one hidden into the one with
      *  none hidden
      */
-	@Test
+    @Test
     void testUnHide() throws IOException {
         wbH.setSheetHidden(0, false);
         assertFalse(wbH.isSheetHidden(0));

Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestWorkbook.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestWorkbook.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestWorkbook.java Sat May 22 20:56:44 2021
@@ -752,16 +752,16 @@ public abstract class BaseTestWorkbook {
         }
     }
 
-	protected void assertSheetOrder(Workbook wb, String... sheets) {
-		StringBuilder sheetNames = new StringBuilder();
-		for(int i = 0;i < wb.getNumberOfSheets();i++) {
-			sheetNames.append(wb.getSheetAt(i).getSheetName()).append(",");
-		}
-		assertEquals(sheets.length, wb.getNumberOfSheets(), "Had: " + sheetNames);
-		for(int i = 0;i < wb.getNumberOfSheets();i++) {
-			assertEquals(sheets[i], wb.getSheetAt(i).getSheetName(), "Had: " + sheetNames);
-		}
-	}
+    protected void assertSheetOrder(Workbook wb, String... sheets) {
+        StringBuilder sheetNames = new StringBuilder();
+        for(int i = 0;i < wb.getNumberOfSheets();i++) {
+            sheetNames.append(wb.getSheetAt(i).getSheetName()).append(",");
+        }
+        assertEquals(sheets.length, wb.getNumberOfSheets(), "Had: " + sheetNames);
+        for(int i = 0;i < wb.getNumberOfSheets();i++) {
+            assertEquals(sheets[i], wb.getSheetAt(i).getSheetName(), "Had: " + sheetNames);
+        }
+    }
 
     @Test
     void test58499() throws IOException {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org