summaryrefslogtreecommitdiff
path: root/starmath/qa
diff options
context:
space:
mode:
authorLuke Dixon <6b8b4567@gmail.com>2010-12-19 15:24:46 +0000
committerJonas Finnemann Jensen <jopsen@gmail.com>2010-12-19 17:15:55 +0100
commitd80b166d6aa125fd639d282ab5d00d1594448d98 (patch)
treec4faae9ee0635b978df6f61bfe088447b76858dd /starmath/qa
parent72228b8893f43443c6ef0c98514e3ef4bdb0f9b0 (diff)
Put brackets around binoms in SmNodeToTextVisitor, with test
Diffstat (limited to 'starmath/qa')
-rw-r--r--starmath/qa/cppunit/test_nodetotextvisitors.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index 45386d13aa7a..e5b9e9338e6b 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -41,6 +41,7 @@
#include <document.hxx>
#include <node.hxx>
#include <visitors.hxx>
+#include <cursor.hxx>
#include "preextstl.h"
#include <cppunit/TestSuite.h>
@@ -72,6 +73,14 @@ struct assertion_traits<String>
SO2_DECL_REF(SmDocShell)
SO2_IMPL_REF(SmDocShell)
+class TestOutputDevice : public OutputDevice
+{
+public:
+ TestOutputDevice()
+ {
+ }
+};
+
using namespace ::com::sun::star;
namespace {
@@ -95,6 +104,7 @@ public:
void SimpleFormats();
void SimpleGreekChars();
void SimpleSpecialChars();
+ void testBinomInBinHor();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(SimpleUnaryOp);
@@ -109,6 +119,7 @@ public:
CPPUNIT_TEST(SimpleFormats);
CPPUNIT_TEST(SimpleGreekChars);
CPPUNIT_TEST(SimpleSpecialChars);
+ CPPUNIT_TEST(testBinomInBinHor);
CPPUNIT_TEST_SUITE_END();
private:
@@ -480,6 +491,32 @@ void Test::parseandparseagain(const char *formula, const char *test_name)
delete pNode2;
}
+void Test::testBinomInBinHor()
+{
+ String sInput, sExpected, sOutput;
+ SmNode* pTree;
+
+ // set up a binom (table) node
+ sInput.AppendAscii("binom a b + c");
+ pTree = SmParser().Parse(sInput);
+ pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef);
+
+ SmCursor aCursor(pTree, xDocShRef);
+ TestOutputDevice aOutputDevice;
+
+ // move forward (more than) enough places to be at the end
+ int i;
+ for (i = 0; i < 8; ++i)
+ aCursor.Move(&aOutputDevice, MoveRight);
+
+ // tack +d on the end, which will put the binom into an SmBinHorNode
+ aCursor.InsertElement(PlusElement);
+ aCursor.InsertText('d');
+
+ sExpected.AppendAscii(" { { binom a b + c } + d } ");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Binom Node in BinHor Node", sExpected, xDocShRef->GetText());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}