Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sw / qa / core / test_ToxMiscTest.cxx
blob67a6320cf81b621c4ef5a5228ea7a3cde99374d4
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 */
10 #include <tox.hxx>
11 #include <cppunit/TestAssert.h>
12 #include <cppunit/TestFixture.h>
13 #include <cppunit/extensions/HelperMacros.h>
15 using namespace sw;
17 class ToxMiscTest : public CppUnit::TestFixture {
18 public:
19 void testTdf73162();
20 CPPUNIT_TEST_SUITE(ToxMiscTest);
21 CPPUNIT_TEST(testTdf73162);
22 CPPUNIT_TEST_SUITE_END();
25 void ToxMiscTest::testTdf73162()
27 //input token string
28 OUString tokenString = "<LS Index Link,65535,><E# ,65535,0,10><X ,65535,\001.\001><ET ,65535,><T ,65535,0,5,.,1><# ,65535,><LE ,65535,>";
30 //create Tokens with the help of input string
31 SwFormTokensHelper tokensHelper(tokenString);
32 SwFormTokens formTokens = tokensHelper.GetTokens();
34 //check the size of token vector / count of tokens
35 CPPUNIT_ASSERT_EQUAL(std::vector<SwFormToken>::size_type(7), formTokens.size());
37 //check individual tokens for proper values
38 //first token
39 SwFormToken token1 = formTokens.at(0);
40 CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_LINK_START, token1.eTokenType);
41 CPPUNIT_ASSERT_EQUAL(OUString("<LS Index Link,65535,>"), token1.GetString());
42 //second token
43 SwFormToken token2 = formTokens.at(1);
44 CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_ENTRY_NO, token2.eTokenType);
45 CPPUNIT_ASSERT_EQUAL(OUString("<E# ,65535,0,10>"), token2.GetString());
46 //third token
47 SwFormToken token3 = formTokens.at(2);
48 CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_TEXT, token3.eTokenType);
49 CPPUNIT_ASSERT_EQUAL(OUString("<X ,65535,\001.\001>"), token3.GetString());
50 //fourth token
51 SwFormToken token4 = formTokens.at(3);
52 CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_ENTRY_TEXT, token4.eTokenType);
53 CPPUNIT_ASSERT_EQUAL(OUString("<ET ,65535,>"), token4.GetString());
54 //fifth token
55 SwFormToken token5 = formTokens.at(4);
56 CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_TAB_STOP, token5.eTokenType);
57 CPPUNIT_ASSERT_EQUAL(OUString("<T ,65535,0,5,.,1>"), token5.GetString());
58 //sixth token
59 SwFormToken token6 = formTokens.at(5);
60 CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_PAGE_NUMS, token6.eTokenType);
61 CPPUNIT_ASSERT_EQUAL(OUString("<# ,65535,>"), token6.GetString());
62 //seventh token
63 SwFormToken token7 = formTokens.at(6);
64 CPPUNIT_ASSERT_EQUAL(FormTokenType::TOKEN_LINK_END, token7.eTokenType);
65 CPPUNIT_ASSERT_EQUAL(OUString("<LE ,65535,>"), token7.GetString());
68 // Put the test suite in the registry
69 CPPUNIT_TEST_SUITE_REGISTRATION(ToxMiscTest);
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */