summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-09-14 15:22:20 +0200
committerEike Rathke <erack@redhat.com>2016-09-23 15:22:38 +0000
commit3e22dfa5eb1ccebdc719a671d23bde7ccab256fb (patch)
treec3890b2a33cc298ad786c50a9d5879531fc6afc4 /sc/qa/unit
parent7d8196ea2f4ec3634dbad7367345e62c4ea9893d (diff)
convert formula error codes to scoped enum
Change-Id: I5ff214bf1ec9031e30344bc125bc99916fd11bfb Reviewed-on: https://gerrit.libreoffice.org/28897 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/helper/qahelper.cxx4
-rw-r--r--sc/qa/unit/helper/shared_test_impl.hxx5
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx6
-rw-r--r--sc/qa/unit/ucalc.cxx10
-rw-r--r--sc/qa/unit/ucalc_formula.cxx48
-rw-r--r--sc/qa/unit/ucalc_pivottable.cxx6
6 files changed, 40 insertions, 39 deletions
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 7e74465a5cf1..7153c4b69c49 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -18,7 +18,7 @@
#include <svx/svdoole2.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/justifyitem.hxx>
-
+#include <formula/errorcodes.hxx>
#include <cppunit/Asserter.h>
#include <cppunit/AdditionalMessage.h>
@@ -522,7 +522,7 @@ bool isFormulaWithoutError(ScDocument& rDoc, const ScAddress& rPos)
if (!pFC)
return false;
- return pFC->GetErrCode() == 0;
+ return pFC->GetErrCode() == FormulaError::NONE;
}
OUString toString(
diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx
index 0c274816c20c..7a27d31a5927 100644
--- a/sc/qa/unit/helper/shared_test_impl.hxx
+++ b/sc/qa/unit/helper/shared_test_impl.hxx
@@ -14,6 +14,7 @@
#include "conditio.hxx"
#include "document.hxx"
#include "formulacell.hxx"
+#include <formula/errorcodes.hxx>
struct FindCondFormatByEnclosingRange
{
@@ -259,8 +260,8 @@ void testFunctionsExcel2010_Impl( ScDocument& rDoc )
OString::number( rDoc.GetValue( ScAddress( 2, nRow, 0)) );
ScFormulaCell* pFC = rDoc.GetFormulaCell( ScAddress( 1, nRow, 0) );
- if ( pFC && pFC->GetErrCode() != 0 )
- aStr += ", error code =" + OString::number( pFC->GetErrCode() );
+ if ( pFC && pFC->GetErrCode() != FormulaError::NONE )
+ aStr += ", error code =" + OString::number( (int)pFC->GetErrCode() );
CPPUNIT_ASSERT_MESSAGE( OString( "Expected a formula cell without error at row " +
aStr ).getStr(), isFormulaWithoutError( rDoc, ScAddress( 1, nRow, 0)));
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 9adc1a055d67..4b53e2d4a3ff 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -3364,8 +3364,8 @@ void ScFiltersTest::testVBAUserFunctionXLSM()
CPPUNIT_ASSERT_EQUAL(OUString("=MYFUNC()"), aFormula);
// Check the formula state after the load.
- sal_uInt16 nErrCode = pFC->GetErrCode();
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0), nErrCode);
+ FormulaError nErrCode = pFC->GetErrCode();
+ CPPUNIT_ASSERT_EQUAL(0, (int)nErrCode);
// Check the result.
CPPUNIT_ASSERT_EQUAL(42.0, rDoc.GetValue(ScAddress(0,0,0)));
@@ -3409,7 +3409,7 @@ void ScFiltersTest::testErrorOnExternalReferences()
ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0,0,0));
CPPUNIT_ASSERT(pFC);
- CPPUNIT_ASSERT_EQUAL(formula::errNoName, pFC->GetErrCode());
+ CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoName, (int)pFC->GetErrCode());
if (!checkFormula(rDoc, ScAddress(0,0,0), "'file:///Path/To/FileA.ods'#$Sheet1.A1A"))
CPPUNIT_FAIL("Formula changed");
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7e8654f3ea0e..0db6a1c270be 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -900,12 +900,12 @@ void Test::testValueIterator()
bool bHas = false;
size_t nCheckPos = 0;
double fVal;
- sal_uInt16 nErr;
+ FormulaError nErr;
for (bHas = aIter.GetFirst(fVal, nErr); bHas; bHas = aIter.GetNext(fVal, nErr), ++nCheckPos)
{
CPPUNIT_ASSERT_MESSAGE("Iteration longer than expected.", nCheckPos < nCheckLen);
CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos], fVal);
- CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0), nErr);
+ CPPUNIT_ASSERT_EQUAL(0, (int)nErr);
}
}
@@ -5776,8 +5776,8 @@ void Test::testFormulaWizardSubformula()
m_pDoc->SetString(ScAddress(1,2,0), "=gibberish"); // B3
ScSimpleFormulaCalculator aFCell1( m_pDoc, ScAddress(0,0,0), "=B1:B3", true );
- sal_uInt16 nErrCode = aFCell1.GetErrCode();
- CPPUNIT_ASSERT( nErrCode == 0 || aFCell1.IsMatrix() );
+ FormulaError nErrCode = aFCell1.GetErrCode();
+ CPPUNIT_ASSERT( nErrCode == FormulaError::NONE || aFCell1.IsMatrix() );
CPPUNIT_ASSERT_EQUAL( OUString("{1;#DIV/0!;#NAME?}"), aFCell1.GetString().getString() );
m_pDoc->SetString(ScAddress(1,0,0), "=NA()"); // B1
@@ -5785,7 +5785,7 @@ void Test::testFormulaWizardSubformula()
m_pDoc->SetString(ScAddress(1,2,0), "=1+2"); // B3
ScSimpleFormulaCalculator aFCell2( m_pDoc, ScAddress(0,0,0), "=B1:B3", true );
nErrCode = aFCell2.GetErrCode();
- CPPUNIT_ASSERT( nErrCode == 0 || aFCell2.IsMatrix() );
+ CPPUNIT_ASSERT( nErrCode == FormulaError::NONE || aFCell2.IsMatrix() );
CPPUNIT_ASSERT_EQUAL( OUString("{#N/A;2;3}"), aFCell2.GetString().getString() );
m_pDoc->DeleteTab(0);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 38f15fadcafd..c3436863c09a 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1141,11 +1141,11 @@ void Test::testFormulaRefUpdate()
aPos = ScAddress(2,1,0);
ScFormulaCell* pFC = m_pDoc->GetFormulaCell(aPos);
CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
- CPPUNIT_ASSERT_EQUAL(formula::errNoRef, pFC->GetErrCode());
+ CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoRef, (int)pFC->GetErrCode());
aPos = ScAddress(2,2,0);
pFC = m_pDoc->GetFormulaCell(aPos);
CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
- CPPUNIT_ASSERT_EQUAL(formula::errNoRef, pFC->GetErrCode());
+ CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoRef, (int)pFC->GetErrCode());
// Clear all and start over.
clearRange(m_pDoc, ScRange(0,0,0,10,10,0));
@@ -1245,11 +1245,11 @@ void Test::testFormulaRefUpdate()
// Both A4 and A5 should show #REF! errors.
pFC = m_pDoc->GetFormulaCell(ScAddress(0,3,0));
CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
- CPPUNIT_ASSERT_EQUAL(formula::errNoRef, pFC->GetErrCode());
+ CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoRef, (int)pFC->GetErrCode());
pFC = m_pDoc->GetFormulaCell(ScAddress(0,4,0));
CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
- CPPUNIT_ASSERT_EQUAL(formula::errNoRef, pFC->GetErrCode());
+ CPPUNIT_ASSERT_EQUAL((int)FormulaError::NoRef, (int)pFC->GetErrCode());
m_pDoc->DeleteTab(0);
}
@@ -1862,7 +1862,7 @@ void Test::testFormulaRefUpdateInsertRows()
rFunc.InsertCells(ScRange(0,1,0,MAXCOL,3,0), &aMark, INS_INSROWS_BEFORE, false, true);
ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,5,0));
CPPUNIT_ASSERT(pFC);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula cell should not be an error.", static_cast<sal_uInt16>(0), pFC->GetErrCode());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula cell should not be an error.", 0, (int)pFC->GetErrCode());
ASSERT_DOUBLES_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,5,0)));
ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "MAX(A7:A9)", "Wrong formula!");
@@ -3547,19 +3547,19 @@ void Test::testFuncSUM()
// Set #DIV/0! error to A3. A4 should also inherit this error.
m_pDoc->SetString(ScAddress(0,2,0), "=1/0");
- sal_uInt16 nErr = m_pDoc->GetErrCode(ScAddress(0,2,0));
+ FormulaError nErr = m_pDoc->GetErrCode(ScAddress(0,2,0));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Cell should have a division by zero error.",
- errDivisionByZero, nErr);
+ (int)FormulaError::DivisionByZero, (int)nErr);
nErr = m_pDoc->GetErrCode(ScAddress(0,3,0));
CPPUNIT_ASSERT_EQUAL_MESSAGE("SUM should have also inherited a div-by-zero error.",
- errDivisionByZero, nErr);
+ (int)FormulaError::DivisionByZero, (int)nErr);
// Set #NA! to A2. A4 should now inherit this error.
m_pDoc->SetString(ScAddress(0,1,0), "=NA()");
nErr = m_pDoc->GetErrCode(ScAddress(0,1,0));
- CPPUNIT_ASSERT_MESSAGE("A2 should be an error.", nErr);
+ CPPUNIT_ASSERT_MESSAGE("A2 should be an error.", nErr != FormulaError::NONE);
CPPUNIT_ASSERT_EQUAL_MESSAGE("A4 should have inherited the same error as A2.",
- nErr, m_pDoc->GetErrCode(ScAddress(0,3,0)));
+ (int)nErr, (int)m_pDoc->GetErrCode(ScAddress(0,3,0)));
m_pDoc->DeleteTab(0);
}
@@ -3642,8 +3642,8 @@ void Test::testFuncSUMPRODUCT()
// Force an error in C2 and test ForcedArray matrix error propagation.
m_pDoc->SetString( 2, 1, 0, "=1/0");
- sal_uInt16 nError = m_pDoc->GetErrCode(aPos);
- CPPUNIT_ASSERT_MESSAGE("Formula result should be a propagated error", nError);
+ FormulaError nError = m_pDoc->GetErrCode(aPos);
+ CPPUNIT_ASSERT_MESSAGE("Formula result should be a propagated error", nError != FormulaError::NONE);
// Test ForceArray propagation of SUMPRODUCT parameters to ABS and + operator.
// => ABS({-3,4})*({-3,4}+{-3,4}) => {3,4}*{-6,8} => {-18,32} => 14
@@ -3715,8 +3715,8 @@ void Test::testFuncMIN()
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCols);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), nRows);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in C1 is invalid.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(2,0,0)));
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in C2 is invalid.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(2,1,0)));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in C1 is invalid.", 0, (int)m_pDoc->GetErrCode(ScAddress(2,0,0)));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in C2 is invalid.", 0, (int)m_pDoc->GetErrCode(ScAddress(2,1,0)));
CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,0,0)));
CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,1,0)));
@@ -3962,8 +3962,8 @@ void Test::testFuncCHOOSE()
m_pDoc->InsertTab(0, "Formula");
m_pDoc->SetString(ScAddress(0,0,0), "=CHOOSE(B1;\"one\";\"two\";\"three\")");
- sal_uInt16 nError = m_pDoc->GetErrCode(ScAddress(0,0,0));
- CPPUNIT_ASSERT_MESSAGE("Formula result should be an error since B1 is still empty.", nError);
+ FormulaError nError = m_pDoc->GetErrCode(ScAddress(0,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Formula result should be an error since B1 is still empty.", nError != FormulaError::NONE);
m_pDoc->SetValue(ScAddress(1,0,0), 1.0);
CPPUNIT_ASSERT_EQUAL(OUString("one"), m_pDoc->GetString(ScAddress(0,0,0)));
m_pDoc->SetValue(ScAddress(1,0,0), 2.0);
@@ -3972,7 +3972,7 @@ void Test::testFuncCHOOSE()
CPPUNIT_ASSERT_EQUAL(OUString("three"), m_pDoc->GetString(ScAddress(0,0,0)));
m_pDoc->SetValue(ScAddress(1,0,0), 4.0);
nError = m_pDoc->GetErrCode(ScAddress(0,0,0));
- CPPUNIT_ASSERT_MESSAGE("Formula result should be an error due to out-of-bound input..", nError);
+ CPPUNIT_ASSERT_MESSAGE("Formula result should be an error due to out-of-bound input..", nError != FormulaError::NONE);
m_pDoc->DeleteTab(0);
}
@@ -4285,9 +4285,9 @@ void Test::testFuncLOOKUP()
printRange(m_pDoc, ScRange(0,4,0,1,6,0), "Data range for LOOKUP.");
// Values for B5:B7 should be 1, 2, and 3.
- CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(1,4,0)));
- CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(1,5,0)));
- CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", static_cast<sal_uInt16>(0), m_pDoc->GetErrCode(ScAddress(1,6,0)));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", 0, (int)m_pDoc->GetErrCode(ScAddress(1,4,0)));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", 0, (int)m_pDoc->GetErrCode(ScAddress(1,5,0)));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula should not have an error code.", 0, (int)m_pDoc->GetErrCode(ScAddress(1,6,0)));
ASSERT_DOUBLES_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,4,0)));
ASSERT_DOUBLES_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,5,0)));
@@ -4923,7 +4923,7 @@ void Test::testFuncINDIRECT2()
// Check formula cell error
ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,9,2));
CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
- CPPUNIT_ASSERT_MESSAGE("This formula cell should be an error.", pFC->GetErrCode() != 0);
+ CPPUNIT_ASSERT_MESSAGE("This formula cell should be an error.", pFC->GetErrCode() != FormulaError::NONE);
m_pDoc->DeleteTab(2);
m_pDoc->DeleteTab(1);
@@ -5620,15 +5620,15 @@ void Test::testExternalRefFunctions()
// areas these tests may be adapted.
m_pDoc->SetString(0, 0, 0, "=SUM('file:///extdata.fake'#Data.B1:AMJ1048575)");
ScFormulaCell* pFC = m_pDoc->GetFormulaCell( ScAddress(0,0,0));
- sal_uInt16 nErr = pFC->GetErrCode();
- CPPUNIT_ASSERT_EQUAL_MESSAGE("huge external range reference expected to yield errMatrixSize", errMatrixSize, nErr);
+ FormulaError nErr = pFC->GetErrCode();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("huge external range reference expected to yield FormulaError::MatrixSize", (int)FormulaError::MatrixSize, (int)nErr);
ScMarkData aMark;
aMark.SelectOneTable(0);
m_pDoc->InsertMatrixFormula(0,0,0,0, aMark, "'file:///extdata.fake'#Data.B1:AMJ1048575");
pFC = m_pDoc->GetFormulaCell( ScAddress(0,0,0));
nErr = pFC->GetErrCode();
- CPPUNIT_ASSERT_EQUAL_MESSAGE("huge external range reference expected to yield errMatrixSize", errMatrixSize, nErr);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("huge external range reference expected to yield FormulaError::MatrixSize", (int)FormulaError::MatrixSize, (int)nErr);
SCSIZE nMatCols, nMatRows;
const ScMatrix* pMat = pFC->GetMatrix();
CPPUNIT_ASSERT_MESSAGE("matrix expected", pMat != nullptr);
diff --git a/sc/qa/unit/ucalc_pivottable.cxx b/sc/qa/unit/ucalc_pivottable.cxx
index c8aa1b3930cf..9bf5522186bf 100644
--- a/sc/qa/unit/ucalc_pivottable.cxx
+++ b/sc/qa/unit/ucalc_pivottable.cxx
@@ -19,6 +19,7 @@
#include "stringutil.hxx"
#include "dbdocfun.hxx"
+#include <formula/errorcodes.hxx>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
@@ -2304,11 +2305,10 @@ void Test::testFuncGETPIVOTDATALeafAccess()
m_pDoc->CalcAll();
- const sal_uInt16 nNoError = 0; // no error
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
{
- sal_uInt16 nErr = m_pDoc->GetErrCode(ScAddress(4,i,1));
- CPPUNIT_ASSERT_EQUAL(nNoError, nErr);
+ FormulaError nErr = m_pDoc->GetErrCode(ScAddress(4,i,1));
+ CPPUNIT_ASSERT_EQUAL((sal_uInt16)FormulaError::NONE, (sal_uInt16)nErr);
double fVal = m_pDoc->GetValue(ScAddress(4,i,1));
CPPUNIT_ASSERT_EQUAL(aChecks[i].mfResult, fVal);
}