sc: check the reference operator combinations against a real file
UnionSpillIntersectionOperatorTest.xlsx was written by the producing application, so the results stored in it are the ones that application computes. Each row compares one with ours, the sheet's master cell says whether every row agrees, and rows refused at the formula bar keep the refused formula as text. It covers the @, # and % operators next to the range, union and intersection operators, alone and combined. The rows are checked against the stored results, then again after a recalculation and after an xlsx save and reload, so both the values the file came with and a fresh evaluation of our own are covered. The whole verdict column is reported in one go, naming for each failing row the two values compared and the tested cell's value and formula. Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> Change-Id: I26a970d82ba5c96737455d75e85b90aec3d22004 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10165 Tested-by: Jenkins CPCI <releng@collaboraoffice.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit f45435e3cf797d08dc13f85c4b2a6cad0dd8d77a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210315 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Jenkins
This commit is contained in:
committed by
Xisco Fauli
parent
38fb197b05
commit
123f934680
Binary file not shown.
@@ -14,6 +14,7 @@
|
||||
#include <address.hxx>
|
||||
#include <document.hxx>
|
||||
#include <rtl/string.hxx>
|
||||
#include <rtl/ustring.hxx>
|
||||
|
||||
class DynamicArrayTest : public ScModelTestBase
|
||||
{
|
||||
@@ -26,25 +27,54 @@ public:
|
||||
|
||||
namespace
|
||||
{
|
||||
// Walk column C from row 5 down to nLastRow on the given sheet.
|
||||
// Every non-empty C cell is a per-row equality comparison that the
|
||||
// fixture expects to evaluate to 1. A failure reports the row that
|
||||
// disagreed so the offending scenario is easy to spot.
|
||||
void assertRowChecks(ScDocument& rDocument, SCTAB nTab, SCROW nLastRow)
|
||||
// Walk column C from row 5 down to nLastRow on the given sheet. Every non-empty C cell is an
|
||||
// equality comparison for that row and has to evaluate to 1. The whole column is read before
|
||||
// anything is reported, so one run lists every row that disagreed instead of stopping at the
|
||||
// first one, and the report says at which stage of the test they disagreed.
|
||||
void assertRowChecks(ScDocument& rDocument, SCTAB nTab, SCROW nLastRow, const char* pStage = "")
|
||||
{
|
||||
OString aRows;
|
||||
for (SCROW nRow = 4; nRow <= nLastRow; ++nRow)
|
||||
{
|
||||
ScAddress aPosition(2, nRow, nTab);
|
||||
if (rDocument.GetCellType(aPosition) == CELLTYPE_NONE)
|
||||
continue;
|
||||
const double fValue = rDocument.GetValue(aPosition);
|
||||
if (fValue == 1.0)
|
||||
if (rDocument.GetValue(aPosition) == 1.0)
|
||||
continue;
|
||||
const OString aLabel = "Sheet" + OString::number(nTab + 1) + " C"
|
||||
+ OString::number(nRow + 1)
|
||||
+ " verdict cell did not evaluate to TRUE";
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(aLabel.getStr(), 1.0, fValue);
|
||||
if (!aRows.isEmpty())
|
||||
aRows += ", ";
|
||||
// Print the two values the comparison used, so a failing row already says what we
|
||||
// computed and what was expected.
|
||||
OString aOurs
|
||||
= OUStringToOString(rDocument.GetString(0, nRow, nTab), RTL_TEXTENCODING_UTF8);
|
||||
OString aExpected
|
||||
= OUStringToOString(rDocument.GetString(1, nRow, nTab), RTL_TEXTENCODING_UTF8);
|
||||
aRows += "C" + OString::number(nRow + 1) + " (A=" + aOurs + " B=" + aExpected;
|
||||
// The tested cell is in column F or G, depending on the layout of the row. Print
|
||||
// its value and the formula it reads back as.
|
||||
for (SCCOL nColumn = 5; nColumn <= 6; ++nColumn)
|
||||
{
|
||||
if (rDocument.GetCellType(ScAddress(nColumn, nRow, nTab)) == CELLTYPE_NONE)
|
||||
continue;
|
||||
aRows += OString::Concat(nColumn == 5 ? " F=" : " G=")
|
||||
+ OUStringToOString(rDocument.GetString(nColumn, nRow, nTab),
|
||||
RTL_TEXTENCODING_UTF8);
|
||||
OUString aFormula = rDocument.GetFormula(nColumn, nRow, nTab);
|
||||
if (!aFormula.isEmpty())
|
||||
aRows += " [" + OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8) + "]";
|
||||
}
|
||||
aRows += ")";
|
||||
}
|
||||
if (aRows.isEmpty())
|
||||
return;
|
||||
|
||||
OString aLabel = "Sheet" + OString::number(nTab + 1)
|
||||
+ " verdict cells that did not "
|
||||
"evaluate to TRUE";
|
||||
if (*pStage)
|
||||
aLabel += OString::Concat(" ") + pStage;
|
||||
aLabel += ": " + aRows;
|
||||
CPPUNIT_FAIL(aLabel.getStr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +117,29 @@ CPPUNIT_TEST_FIXTURE(DynamicArrayTest, testDroppedImplicitIntersectionIsPutBack)
|
||||
CPPUNIT_ASSERT_EQUAL(u"=$H$5#"_ustr, pDocument->GetFormula(0, 33, 2));
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(DynamicArrayTest, testUnionSpillIntersectionOperatorXlsxRoundTrip)
|
||||
{
|
||||
createScDoc("functions/dynamic_array/xlsx/UnionSpillIntersectionOperatorTest.xlsx");
|
||||
|
||||
auto checkVerdicts = [this](const char* pStage) {
|
||||
ScDocument* pDocument = getScDoc();
|
||||
assertRowChecks(*pDocument, 0, 200, pStage);
|
||||
};
|
||||
|
||||
// J112 is the shape OOXML saves without its @, so the import puts it back.
|
||||
CPPUNIT_ASSERT_EQUAL(u"=@$I$112#"_ustr, getScDoc()->GetFormula(9, 111, 0));
|
||||
|
||||
// The workbook is another application's, so the first check is against its stored
|
||||
// results and each later one against ours, with the save and reload covering the export.
|
||||
checkVerdicts("on import");
|
||||
getScDoc()->CalcAll();
|
||||
checkVerdicts("after a recalculation");
|
||||
saveAndReload(TestFilter::XLSX);
|
||||
checkVerdicts("after a save and reload");
|
||||
getScDoc()->CalcAll();
|
||||
checkVerdicts("after a recalculation of the reloaded document");
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
||||
Reference in New Issue
Block a user