}
@Test
public void testSortByColumns() {
Worksheet sheet1 = (Worksheet)_workbook.getSheet("Sheet1");
Row row1 = sheet1.getRow(0);
Row row2 = sheet1.getRow(1);
Row row3 = sheet1.getRow(2);
Row row4 = sheet1.getRow(3);
Row row5 = sheet1.getRow(4);
Row row6 = sheet1.getRow(5);
Row row7 = sheet1.getRow(6);
Row row8 = sheet1.getRow(7);
Row row9 = sheet1.getRow(8);
Row row10 = sheet1.getRow(9);
Row row11 = sheet1.getRow(10);
Row row12 = sheet1.getRow(11);
Row row13 = sheet1.getRow(12);
assertEquals(1, row1.getCell(0).getNumericCellValue(), 0.0000000000000001); //A1: 1
assertEquals(2, row2.getCell(0).getNumericCellValue(), 0.0000000000000001); //A2: 2
assertEquals(3, row3.getCell(0).getNumericCellValue(), 0.0000000000000001); //A3: 3
assertEquals("a", row4.getCell(0).getStringCellValue()); //A4: "a"
assertEquals("b", row5.getCell(0).getStringCellValue()); //A5: "b"
assertEquals("c", row6.getCell(0).getStringCellValue()); //A6: "c"
assertEquals(ErrorConstants.ERROR_VALUE, row7.getCell(0).getErrorCellValue()); //A7: #VALUE!
assertEquals(ErrorConstants.ERROR_REF, row8.getCell(0).getErrorCellValue()); //A8: #REF!
assertNull(row9.getCell(0)); //A9: null
assertEquals(ErrorConstants.ERROR_VALUE, row10.getCell(0).getErrorCellValue()); //A10: #VALUE!
assertEquals(true, row11.getCell(0).getBooleanCellValue()); //A11: TRUE
assertEquals(false, row12.getCell(0).getBooleanCellValue()); //A12: FALSE
assertEquals(1, row1.getCell(1).getNumericCellValue(), 0.0000000000000001); //B1: 1
assertEquals(2, row2.getCell(1).getNumericCellValue(), 0.0000000000000001); //B2: 2
assertEquals(3, row3.getCell(1).getNumericCellValue(), 0.0000000000000001); //B3: 3
assertEquals(4, row4.getCell(1).getNumericCellValue(), 0.0000000000000001); //B4: 4
assertEquals(5, row5.getCell(1).getNumericCellValue(), 0.0000000000000001); //B5: 5
assertEquals(6, row6.getCell(1).getNumericCellValue(), 0.0000000000000001); //B6: 6
assertEquals(7, row7.getCell(1).getNumericCellValue(), 0.0000000000000001); //B7: 7
assertEquals(8, row8.getCell(1).getNumericCellValue(), 0.0000000000000001); //B8: 8
assertEquals(9, row9.getCell(1).getNumericCellValue(), 0.0000000000000001); //B9: 9
assertEquals(10, row10.getCell(1).getNumericCellValue(), 0.0000000000000001); //B10: 10
assertEquals(11, row11.getCell(1).getNumericCellValue(), 0.0000000000000001); //B11: 11
assertEquals(12, row12.getCell(1).getNumericCellValue(), 0.0000000000000001); //B12: 12
//C9: =B8
Cell cellC9 = row9.getCell(2);
CellValue valueC9 = _evaluator.evaluate(cellC9);
assertEquals(8, valueC9.getNumberValue(), 0.0000000000000001);
assertEquals(Cell.CELL_TYPE_NUMERIC, valueC9.getCellType());
testToFormulaString(cellC9, "B8");
//C13: =B12
Cell cellC13 = row13.getCell(2);
CellValue valueC13 = _evaluator.evaluate(cellC13);
assertEquals(12, valueC13.getNumberValue(), 0.0000000000000001);
assertEquals(Cell.CELL_TYPE_NUMERIC, valueC13.getCellType());
testToFormulaString(cellC13, "B12");
//Sort A1:C12
ChangeInfo info = BookHelper.sort(sheet1, 0, 0, 11, 2, ((RangeImpl)Utils.getRange(sheet1, 0, 0)).getRefs().iterator().next(), false,
null, 0, false, null, false, BookHelper.SORT_HEADER_NO, 0, false, false, 0,
BookHelper.SORT_NORMAL_DEFAULT, BookHelper.SORT_NORMAL_DEFAULT, BookHelper.SORT_NORMAL_DEFAULT);
Set<Ref> last = info.getToEval();
Set<Ref> all = info.getAffected();
_evaluator.notifySetFormula(cellC13);
assertEquals(1, row1.getCell(0).getNumericCellValue(), 0.0000000000000001); //A1: 1
assertEquals(2, row2.getCell(0).getNumericCellValue(), 0.0000000000000001); //A2: 2
assertEquals(3, row3.getCell(0).getNumericCellValue(), 0.0000000000000001); //A3: 3
assertEquals("a", row4.getCell(0).getStringCellValue()); //A4: "a"
assertEquals("b", row5.getCell(0).getStringCellValue()); //A5: "b"
assertEquals("c", row6.getCell(0).getStringCellValue()); //A6: "c"
assertEquals(false, row7.getCell(0).getBooleanCellValue()); //A7: FALSE
assertEquals(true, row8.getCell(0).getBooleanCellValue()); //A8: TRUE
assertEquals(ErrorConstants.ERROR_VALUE, row9.getCell(0).getErrorCellValue()); //A9: #VALUE!
assertEquals(ErrorConstants.ERROR_REF, row10.getCell(0).getErrorCellValue()); //A10: #REF!
assertEquals(ErrorConstants.ERROR_VALUE, row11.getCell(0).getErrorCellValue()); //A11: #VALUE!
assertNull(row12.getCell(0)); //A9: null
assertEquals(1, row1.getCell(1).getNumericCellValue(), 0.0000000000000001); //B1: 1
assertEquals(2, row2.getCell(1).getNumericCellValue(), 0.0000000000000001); //B2: 2
assertEquals(3, row3.getCell(1).getNumericCellValue(), 0.0000000000000001); //B3: 3
assertEquals(4, row4.getCell(1).getNumericCellValue(), 0.0000000000000001); //B4: 4
assertEquals(5, row5.getCell(1).getNumericCellValue(), 0.0000000000000001); //B5: 5
assertEquals(6, row6.getCell(1).getNumericCellValue(), 0.0000000000000001); //B6: 6
assertEquals(12, row7.getCell(1).getNumericCellValue(), 0.0000000000000001); //B7: 12
assertEquals(11, row8.getCell(1).getNumericCellValue(), 0.0000000000000001); //B8: 11
assertEquals(7, row9.getCell(1).getNumericCellValue(), 0.0000000000000001); //B9: 7
assertEquals(8, row10.getCell(1).getNumericCellValue(), 0.0000000000000001); //B10: 8
assertEquals(10, row11.getCell(1).getNumericCellValue(), 0.0000000000000001); //B11: 10
assertEquals(9, row12.getCell(1).getNumericCellValue(), 0.0000000000000001); //B12: 9
//C9 -> C12: =B8 -> B11
Cell cellC12 = row12.getCell(2);
CellValue valueC12 = _evaluator.evaluate(cellC12);
assertEquals(10, valueC12.getNumberValue(), 0.0000000000000001);
assertEquals(Cell.CELL_TYPE_NUMERIC, valueC12.getCellType());
testToFormulaString(cellC12, "B11");
//C13: =B12
cellC13 = row13.getCell(2);
valueC13 = _evaluator.evaluate(cellC13);
assertEquals(9, valueC13.getNumberValue(), 0.0000000000000001);
assertEquals(Cell.CELL_TYPE_NUMERIC, valueC13.getCellType());
testToFormulaString(cellC13, "B12");
}