[Libreoffice-commits] core.git: sw/CppunitTest_sw_uwriter.mk sw/qa
Varun
varun.dhall at studentpartner.com
Mon Jun 13 11:18:05 UTC 2016
sw/CppunitTest_sw_uwriter.mk | 1
sw/qa/core/test_ToxMiscTest.cxx | 71 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
New commits:
commit a3625c415bd9d297ab65a1016b2c8d8c6991e981
Author: Varun <varun.dhall at studentpartner.com>
Date: Sun Jun 12 02:54:31 2016 +0530
Added Test for tdf#73162 TOC/Index
Change-Id: I1bd6dc18277aa009c23c75b85932d1c93fc13b5e
Reviewed-on: https://gerrit.libreoffice.org/26190
Reviewed-by: Michael Stahl <mstahl at redhat.com>
Tested-by: Michael Stahl <mstahl at redhat.com>
diff --git a/sw/CppunitTest_sw_uwriter.mk b/sw/CppunitTest_sw_uwriter.mk
index 465aac5..b9644ed 100644
--- a/sw/CppunitTest_sw_uwriter.mk
+++ b/sw/CppunitTest_sw_uwriter.mk
@@ -17,6 +17,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sw_uwriter, \
sw/qa/core/test_ToxWhitespaceStripper \
sw/qa/core/test_ToxLinkProcessor \
sw/qa/core/test_ToxTextGenerator \
+ sw/qa/core/test_ToxMiscTest \
))
$(eval $(call gb_CppunitTest_use_library_objects,sw_uwriter,sw))
diff --git a/sw/qa/core/test_ToxMiscTest.cxx b/sw/qa/core/test_ToxMiscTest.cxx
new file mode 100644
index 0000000..0b668f4
--- /dev/null
+++ b/sw/qa/core/test_ToxMiscTest.cxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "tox.hxx"
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace sw;
+
+class ToxMiscTest : public CppUnit::TestFixture {
+public:
+ void testTdf73162();
+ CPPUNIT_TEST_SUITE(ToxMiscTest);
+ CPPUNIT_TEST(testTdf73162);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void ToxMiscTest::testTdf73162()
+{
+ //input token string
+ OUString tokenString = "<LS Index Link,65535,><E# ,65535,0,10><X ,65535,\001.\001><ET ,65535,><T ,65535,0,5,.,1><# ,65535,><LE ,65535,>";
+
+ //create Tokens with the help of input string
+ SwFormTokensHelper tokensHelper(tokenString);
+ SwFormTokens formTokens = tokensHelper.GetTokens();
+
+ //check the size of token vector / count of tokens
+ CPPUNIT_ASSERT_EQUAL(std::vector<SwFormToken>::size_type(7), formTokens.size());
+
+ //check individual tokens for proper values
+ //first token
+ SwFormToken token1 = formTokens.at(0);
+ CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_LINK_START, token1.eTokenType);
+ CPPUNIT_ASSERT_EQUAL(OUString("<LS Index Link,65535,>"), token1.GetString());
+ //second token
+ SwFormToken token2 = formTokens.at(1);
+ CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_ENTRY_NO, token2.eTokenType);
+ CPPUNIT_ASSERT_EQUAL(OUString("<E# ,65535,0,10>"), token2.GetString());
+ //third token
+ SwFormToken token3 = formTokens.at(2);
+ CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_TEXT, token3.eTokenType);
+ CPPUNIT_ASSERT_EQUAL(OUString("<X ,65535,\001.\001>"), token3.GetString());
+ //fourth token
+ SwFormToken token4 = formTokens.at(3);
+ CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_ENTRY_TEXT, token4.eTokenType);
+ CPPUNIT_ASSERT_EQUAL(OUString("<ET ,65535,>"), token4.GetString());
+ //fifth token
+ SwFormToken token5 = formTokens.at(4);
+ CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_TAB_STOP, token5.eTokenType);
+ CPPUNIT_ASSERT_EQUAL(OUString("<T ,65535,0,5,.,1>"), token5.GetString());
+ //sixth token
+ SwFormToken token6 = formTokens.at(5);
+ CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_PAGE_NUMS, token6.eTokenType);
+ CPPUNIT_ASSERT_EQUAL(OUString("<# ,65535,>"), token6.GetString());
+ //seventh token
+ SwFormToken token7 = formTokens.at(6);
+ CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_LINK_END, token7.eTokenType);
+ CPPUNIT_ASSERT_EQUAL(OUString("<LE ,65535,>"), token7.GetString());
+}
+
+// Put the test suite in the registry
+CPPUNIT_TEST_SUITE_REGISTRATION(ToxMiscTest);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list