use insert function instead of for loop
[LibreOffice.git] / oox / qa / token / tokenmap-test.cxx
blobb8b29911c30f7f1f1e4415b449dc6c199aad39d7
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 <cppunit/TestAssert.h>
11 #include <cppunit/TestFixture.h>
12 #include <cppunit/extensions/HelperMacros.h>
13 #include <cppunit/plugin/TestPlugIn.h>
15 #include <oox/token/tokenmap.hxx>
16 #include <oox/token/tokens.hxx>
18 using namespace com::sun::star::uno;
20 namespace oox {
22 class TokenmapTest: public CppUnit::TestFixture
24 public:
25 void test_roundTrip();
26 void test_roundTripUnicode();
28 CPPUNIT_TEST_SUITE(TokenmapTest);
30 CPPUNIT_TEST(test_roundTrip);
31 CPPUNIT_TEST(test_roundTripUnicode);
32 CPPUNIT_TEST_SUITE_END();
35 void TokenmapTest::test_roundTrip()
37 for ( sal_Int32 nToken = 0; nToken < XML_TOKEN_COUNT; ++nToken )
39 // check that the getIdentifier <-> getToken roundtrip works
40 Sequence< sal_Int8 > rUtf8Name = TokenMap::getUtf8TokenName(nToken);
41 sal_Int32 ret = TokenMap::getTokenFromUtf8(std::string_view(
42 reinterpret_cast<const char*>(rUtf8Name.getConstArray()), rUtf8Name.getLength()));
43 CPPUNIT_ASSERT_EQUAL(ret, nToken);
47 void TokenmapTest::test_roundTripUnicode()
49 for (sal_Int32 nToken = 0; nToken < XML_TOKEN_COUNT; ++nToken)
51 // check that the getIdentifier <-> getToken roundtrip works for OUString
52 OUString sName = TokenMap::getUnicodeTokenName(nToken);
53 sal_Int32 ret = oox::TokenMap::getTokenFromUnicode(sName);
54 CPPUNIT_ASSERT_EQUAL(ret, nToken);
58 CPPUNIT_TEST_SUITE_REGISTRATION(TokenmapTest);
62 CPPUNIT_PLUGIN_IMPLEMENT();