summaryrefslogtreecommitdiff
path: root/xmloff/qa/unit
diff options
context:
space:
mode:
authorDaniel Sikeler <d.sikeler94@gmail.com>2016-08-12 10:26:28 +0000
committerEike Rathke <erack@redhat.com>2016-08-16 20:31:31 +0000
commitf577a422079c5333caa52e69ad09eb2b83de9134 (patch)
tree09dec5fb643532a9217bda0fb93d55046e437ad7 /xmloff/qa/unit
parent10c6bef34d8f40173f2d87037327706cb20ed33e (diff)
GSoC - implement global tokenhandler for odf-tokens
This generates perfect hash for odf-tokens and use them with the tokenhandler. With added test case to check to and fro mapping between tokens. This is taken from Daniel's work in feature/fastparser branch. Change-Id: I7cf77c1eb6c9dd68fd78108c6e0726507c7672e1 Reviewed-on: https://gerrit.libreoffice.org/28073 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'xmloff/qa/unit')
-rw-r--r--xmloff/qa/unit/tokenmap-test.cxx54
1 files changed, 54 insertions, 0 deletions
diff --git a/xmloff/qa/unit/tokenmap-test.cxx b/xmloff/qa/unit/tokenmap-test.cxx
new file mode 100644
index 000000000000..8a05eb1a1211
--- /dev/null
+++ b/xmloff/qa/unit/tokenmap-test.cxx
@@ -0,0 +1,54 @@
+/* -*- 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 <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include "xmloff/fasttokenhandler.hxx"
+#include "xmloff/token/tokens.hxx"
+
+using namespace std;
+using namespace com::sun::star::uno;
+
+namespace xmloff {
+
+class TokenmapTest: public CppUnit::TestFixture
+{
+public:
+ void test_roundTrip();
+
+ CPPUNIT_TEST_SUITE(TokenmapTest);
+
+ CPPUNIT_TEST(test_roundTrip);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ token::TokenMap tokenMap;
+};
+
+void TokenmapTest::test_roundTrip()
+{
+ for ( sal_Int32 nToken = 0; nToken < XML_TOKEN_COUNT; ++nToken )
+ {
+ // check that the getIdentifier <-> getToken roundtrip works
+ Sequence< sal_Int8 > rUtf8Name = tokenMap.getUtf8TokenName(nToken);
+ sal_Int32 ret = tokenMap.getTokenFromUTF8(
+ reinterpret_cast< const char * >(rUtf8Name.getConstArray()),
+ rUtf8Name.getLength() );
+ CPPUNIT_ASSERT_EQUAL(ret, nToken);
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TokenmapTest);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();