summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorƁukasz Hryniuk <lukasz.hryniuk@wp.pl>2015-08-10 17:13:02 +0200
committerEike Rathke <erack@redhat.com>2015-08-10 22:26:56 +0000
commit066f3132effa9017fe9127e9d311d6ae88d0c729 (patch)
tree3d7e1d82d7aef01eb628cc570954e9dd51b818db
parentfc71e5b4637ece8822e83c844d191f461b2f0177 (diff)
tdf#89387 a few tests for FTEST function
Change-Id: I96747f4ffd070a0d1511cef6f56c9a253949ee97 Reviewed-on: https://gerrit.libreoffice.org/17628 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx54
2 files changed, 56 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 7c54dc02ef68..3e03b5fdb0e3 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -184,6 +184,7 @@ public:
void testFuncRangeOp();
void testFuncFORMULA();
void testFuncTableRef();
+ void testFuncFTEST();
void testExternalRef();
void testExternalRefFunctions();
@@ -514,6 +515,7 @@ public:
CPPUNIT_TEST(testFuncRangeOp);
CPPUNIT_TEST(testFuncFORMULA);
CPPUNIT_TEST(testFuncTableRef);
+ CPPUNIT_TEST(testFuncFTEST);
CPPUNIT_TEST(testExternalRef);
CPPUNIT_TEST(testExternalRefFunctions);
CPPUNIT_TEST(testCopyToDocument);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 720ff5ef027e..0a9fd2d156d3 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -5522,4 +5522,58 @@ void Test::testFuncTableRef()
m_pDoc->DeleteTab(0);
}
+void Test::testFuncFTEST()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ m_pDoc->InsertTab(0, "FTest");
+
+ ScAddress aPos(6,0,0);
+ m_pDoc->SetString(aPos, "=FTEST(A1:C3;D1:F3)");
+ m_pDoc->SetValue(0, 0, 0, 9.0); // A1
+ OUString aVal = m_pDoc->GetString(aPos);
+ CPPUNIT_ASSERT_MESSAGE("FTEST should return #VALUE! for less than 2 values",
+ OUString::createFromAscii("#VALUE!") == aVal);
+ m_pDoc->SetValue(0, 1, 0, 8.0); // A2
+ aVal = m_pDoc->GetString(aPos);
+ CPPUNIT_ASSERT_MESSAGE("FTEST should return #VALUE! for less than 2 values",
+ OUString::createFromAscii("#VALUE!") == aVal);
+ m_pDoc->SetValue(3, 0, 0, 5.0); // D1
+ aVal = m_pDoc->GetString(aPos);
+ CPPUNIT_ASSERT_MESSAGE("FTEST should return #VALUE! for less than 2 values",
+ OUString::createFromAscii("#VALUE!") == aVal);
+ m_pDoc->SetValue(3, 1, 0, 6.0); // D2
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 1.0000, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(1, 0, 0, 6.0); // B1
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.6222, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(1, 1, 0, 8.0); // B2
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.7732, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(4, 0, 0, 7.0); // E1
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.8194, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(4, 1, 0, 4.0); // E2
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.9674, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(2, 0, 0, 3.0); // C1
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.3402, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(5, 0, 0, 28.0); // F1
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.0161, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(2, 1, 0, 9.0); // C2
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.0063, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(5, 1, 0, 4.0); // F2
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.0081, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(0, 2, 0, 2.0); // A3
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.0122, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(3, 2, 0, 8.0); // D3
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.0178, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(1, 2, 0, 4.0); // B3
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.0093, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(4, 2, 0, 7.0); // E3
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.0132, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(5, 2, 0, 5.0); // F3
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.0168, m_pDoc->GetValue(aPos), 10e-4);
+ m_pDoc->SetValue(2, 2, 0, 13.0); // C3
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of FTEST failed", 0.0422, m_pDoc->GetValue(aPos), 10e-4);
+
+ m_pDoc->DeleteTab(0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */