Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public static ReadCellData<?> newInstanceOriginal(BigDecimal numberValue, Intege
public ReadCellData<Object> clone() {
ReadCellData<Object> readCellData = new ReadCellData<>();
readCellData.setType(getType());
readCellData.setRowIndex(getRowIndex());
readCellData.setColumnIndex(getColumnIndex());
readCellData.setNumberValue(getNumberValue());
readCellData.setOriginalNumberValue(getOriginalNumberValue());
readCellData.setStringValue(getStringValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ void readAndWrite(ExcelFormat format) throws Exception {
Assertions.assertEquals("2020年01月01日", row.getDate().getData());
Assertions.assertEquals(2L, (long) row.getInteger1().getData());
Assertions.assertEquals(2L, (long) row.getInteger2());

// A cell read as ReadCellData must tell where the cell is
Assertions.assertEquals(1, row.getDate().getRowIndex());
Assertions.assertEquals(0, row.getDate().getColumnIndex());
Assertions.assertEquals(1, row.getInteger1().getRowIndex());
Assertions.assertEquals(1, row.getInteger1().getColumnIndex());
Assertions.assertEquals(1, row.getFormulaValue().getRowIndex());
Assertions.assertEquals(3, row.getFormulaValue().getColumnIndex());

if (format.toExcelTypeEnum() != ExcelTypeEnum.CSV) {
Assertions.assertEquals(
"B2+C2", row.getFormulaValue().getFormulaData().getFormulaValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.fesod.sheet.metadata.data;

import org.apache.fesod.sheet.enums.CellDataTypeEnum;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand All @@ -44,4 +45,21 @@ private static Boolean booleanFrom(String str) {
cellData.setBooleanValueFromString(str);
return cellData.getBooleanValue();
}

/**
* A clone must describe the same cell, including where the cell is.
*/
@Test
void cloneKeepsCoordinates() {
ReadCellData<String> cellData = new ReadCellData<>(CellDataTypeEnum.STRING, "value");
cellData.setRowIndex(1);
cellData.setColumnIndex(2);

ReadCellData<Object> clone = cellData.clone();

Assertions.assertEquals(CellDataTypeEnum.STRING, clone.getType());
Assertions.assertEquals("value", clone.getStringValue());
Assertions.assertEquals(1, clone.getRowIndex());
Assertions.assertEquals(2, clone.getColumnIndex());
}
}
Loading