Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / qa / unit / functions_test.cxx
blob8efdfa5b0f82571fc2590af229ca49d9a27d37ad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
11 #include "functions_test.hxx"
12 #include <document.hxx>
14 #include <rtl/math.hxx>
16 FunctionsTest::FunctionsTest():
17 ScFilterTestBase()
21 bool FunctionsTest::load(const OUString& rFilter, const OUString& rURL,
22 const OUString& rUserData, SfxFilterFlags nFilterFlags,
23 SotClipboardFormatId nClipboardID,
24 unsigned int nFilterVersion)
26 ScDocShellRef xDocShRef = loadDoc(rURL, rFilter, rUserData,
27 OUString(), nFilterFlags, nClipboardID, nFilterVersion );
28 CPPUNIT_ASSERT(xDocShRef.is());
30 xDocShRef->DoHardRecalc();
32 ScDocument& rDoc = xDocShRef->GetDocument();
34 if(!rtl::math::approxEqual(1.0, rDoc.GetValue(1, 2, 0)))
36 // Cell B3 in Sheet1 has the cumulative success/failure result.
37 // Try to find the actual failure.
38 for(SCTAB tab = 1; tab <= rDoc.GetMaxTableNumber(); ++tab)
40 SCROW maxRow = rDoc.GetLastDataRow(tab, 2, 2, rDoc.MaxRow());
41 for(SCROW row = 0; row <= maxRow; ++row)
43 // Column C has the check result, column D has the formula text.
44 if(rDoc.HasStringData(2, row, tab))
45 continue;
46 if(!rtl::math::approxEqual(1.0, rDoc.GetValue(2, row, 1)))
47 CPPUNIT_FAIL( OUString( "Testing " + rURL + " failed, "
48 + rDoc.GetAllTableNames()[tab] + ".A" + OUString::number(row+1)
49 + " \'" + rDoc.GetString(3, row, 1) + "\'"
50 " result: " + OUString::number(rDoc.GetValue(0, row, 1))
51 + ", expected: " + OUString::number(rDoc.GetValue(1, row, 1)))
52 .toUtf8().getStr());
56 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, rDoc.GetValue(1, 2, 0), 1e-14);
58 xDocShRef->DoClose();
60 return true;
63 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */