sc: add the dynamic-array XLSX import functions test

DynamicArrayFixture.xlsx is a self-checking workbook. The
test loads it, walks column C of each sheet asserting every
verdict cell reads TRUE, and checks each sheet's master cell.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I9f0ad05c5071eb3a0baea5aa5996ea526565b480
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/5791
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 5ccb4ccdd9dc29883c46169b93c642da6e1e4458)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207908
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Tomaž Vajngerl
2026-07-10 01:09:58 +02:00
committed by Xisco Fauli
parent e703f728ff
commit 0d303ccfd2
5 changed files with 94 additions and 0 deletions
@@ -0,0 +1,14 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*-
#
# Copyright the LibreOffice contributors.
#
# SPDX-License-Identifier: MPL-2.0
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call sc_functions_test,dynamic_array))
# vim: set noet sw=4 ts=4:
+1
View File
@@ -140,6 +140,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sc, \
CppunitTest_sc_spreadsheet_functions_test \
CppunitTest_sc_statistical_functions_test \
CppunitTest_sc_text_functions_test \
CppunitTest_sc_dynamic_array_functions_test \
CppunitTest_sc_annotationobj \
CppunitTest_sc_annotationshapeobj \
CppunitTest_sc_annotationsobj \
+2
View File
@@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_use_externals,sc_$(1)_functions_test, \
boost_headers \
mdds_headers \
md4c \
libxml2 \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_$(1)_functions_test, \
@@ -44,6 +45,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_$(1)_functions_test, \
scqahelper \
sfx \
sot \
subsequenttest \
svl \
svt \
svx \
+77
View File
@@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* Copyright the LibreOffice contributors.
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "helper/qahelper.hxx"
#include <address.hxx>
#include <document.hxx>
#include <rtl/string.hxx>
class DynamicArrayTest : public ScModelTestBase
{
public:
DynamicArrayTest()
: ScModelTestBase(u"sc/qa/unit/data"_ustr)
{
}
};
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)
{
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)
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);
}
}
}
CPPUNIT_TEST_FIXTURE(DynamicArrayTest, testDynamicArrayXlsxRoundTrip)
{
createScDoc("functions/dynamic_array/xlsx/DynamicArrayFixture.xlsx");
auto checkVerdicts = [this]() {
ScDocument* pDocument = getScDoc();
// Sheet 1 "CSE Array Spill Cases", master cell A3 = AND(C5:C400).
assertRowChecks(*pDocument, 0, 399);
CPPUNIT_ASSERT_EQUAL(1.0, pDocument->GetValue(ScAddress(0, 2, 0)));
// Sheet 2 "Implicit intersection Operator", master cell A3 = AND(C5:C200).
assertRowChecks(*pDocument, 1, 199);
CPPUNIT_ASSERT_EQUAL(1.0, pDocument->GetValue(ScAddress(0, 2, 1)));
// Sheet 3 "Spill Operator", master cell A3 = AND(C5:C508).
assertRowChecks(*pDocument, 2, 507);
CPPUNIT_ASSERT_EQUAL(1.0, pDocument->GetValue(ScAddress(0, 2, 2)));
};
// The self-checking workbook holds after import, and again after an
// XLSX save and reload.
checkVerdicts();
saveAndReload(TestFilter::XLSX);
checkVerdicts();
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */