summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-01-28 16:49:18 +0200
committerTor Lillqvist <tml@collabora.com>2015-01-28 18:16:44 +0200
commit0132711bce74c6e3a3658ddd35b4973ad2b4cce0 (patch)
tree227ebff6f88c6d7d25e2b0e70874e42c3da17b55
parentd04540a55f533279d2b404223cc625fa251a6ea2 (diff)
Add ROUND test
Change-Id: Ifa0c2bc6767d9d2e9b27c5a6b30929463b20407c
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.cxx53
1 files changed, 53 insertions, 0 deletions
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index f816ab4cef12..21da615e8691 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -455,6 +455,57 @@ struct BinOp : Op
}
};
+struct Round : Area
+{
+ Round() :
+ Area("Round", 200)
+ {
+ }
+
+ virtual ~Round()
+ {
+ }
+
+ virtual void addHeader(ScDocument *pDoc, int nTab) const SAL_OVERRIDE
+ {
+ pDoc->SetString(ScAddress(0,0,nTab), "x");
+ pDoc->SetString(ScAddress(1,0,nTab), "n");
+ pDoc->SetString(ScAddress(2,0,nTab), "ROUND(x,n)");
+ pDoc->SetString(ScAddress(3,0,nTab), "expected");
+ }
+
+ virtual void addRow(ScDocument *pDoc, int nRow, int nTab) const SAL_OVERRIDE
+ {
+ const double nX(comphelper::rng::uniform_real_distribution(0, 100));
+ const int nN(comphelper::rng::uniform_int_distribution(1, 10));
+
+ pDoc->SetValue(ScAddress(0,1+nRow,nTab), nX);
+ pDoc->SetValue(ScAddress(1,1+nRow,nTab), nN);
+
+ pDoc->SetString(ScAddress(2,1+nRow,nTab),
+ "=ROUND(" + ScAddress(0,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) +
+ "," + ScAddress(1,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) +
+ ")");
+
+ pDoc->SetValue(ScAddress(3,1+nRow,nTab), ::rtl::math::round(nX, (short) nN, rtl_math_RoundingMode_Corrected));
+
+ pDoc->SetString(ScAddress(4,1+nRow,nTab),
+ "=IF(ABS(" + ScAddress(2,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) +
+ "-" + ScAddress(3,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) +
+ ")<=3e-10"
+ ",0,1)");
+ }
+
+ virtual OUString getSummaryFormula(ScDocument *pDoc, int nTab) const SAL_OVERRIDE
+ {
+ return "=SUM(" +
+ ScRange(ScAddress(4,1,nTab),
+ ScAddress(4,1+mnRows-1,nTab)).Format(SCA_VALID|SCA_TAB_3D|SCA_VALID_COL|SCA_VALID_ROW|SCA_VALID_TAB, pDoc) +
+ ")";
+ }
+
+};
+
struct Reduction : Op
{
int mnNum;
@@ -629,6 +680,8 @@ IMPL_LINK( ScCalcOptionsDialog, TestClickHdl, PushButton*, )
return ScInterpreter::gaussinv(nArg);
}));
+ xTestDocument->addTest(Round());
+
xTestDocument->addTest(Reduction("Sum", "SUM", 100, 0, -1000, 1000, 3e-10,
[] (double nAccum, double nArg)
{