diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-10-23 04:26:39 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-10-23 04:28:16 +0200 |
commit | eb13f2d92ca7a1688a5b7849b58e0e36f16fe557 (patch) | |
tree | 16024e93d48c3953a0db876b366f4d294fd39f1e /comphelper | |
parent | 7f614ac933524d798724895827b255b0d36dcc6b (diff) |
add inital test for syntaxhighlighter
Test is partly disabled as we still generate invalid tokens
Change-Id: I1a9b03b9bbe2ed7087c6ab7b6d0823ac1d058ba7
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/CppunitTest_comphelper_syntaxhighlight_test.mk | 29 | ||||
-rw-r--r-- | comphelper/qa/unit/syntaxhighlighttest.cxx | 53 |
2 files changed, 82 insertions, 0 deletions
diff --git a/comphelper/CppunitTest_comphelper_syntaxhighlight_test.mk b/comphelper/CppunitTest_comphelper_syntaxhighlight_test.mk new file mode 100644 index 000000000000..3c9960c1d49b --- /dev/null +++ b/comphelper/CppunitTest_comphelper_syntaxhighlight_test.mk @@ -0,0 +1,29 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,comphelper_syntaxhighlight_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,comphelper_syntaxhighlight_test, \ + comphelper/qa/unit/syntaxhighlighttest \ +)) + +$(eval $(call gb_CppunitTest_use_api,comphelper_syntaxhighlight_test, \ + udkapi \ + offapi \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,comphelper_syntaxhighlight_test, \ + comphelper \ + cppuhelper \ + cppu \ + sal \ + $(gb_UWINAPI) \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/comphelper/qa/unit/syntaxhighlighttest.cxx b/comphelper/qa/unit/syntaxhighlighttest.cxx new file mode 100644 index 000000000000..244a1a09a553 --- /dev/null +++ b/comphelper/qa/unit/syntaxhighlighttest.cxx @@ -0,0 +1,53 @@ +/* -*- 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 <comphelper/syntaxhighlight.hxx> +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" +#include "rtl/ustring.hxx" + +#include <vector> + +class SyntaxHighlightTest : public CppUnit::TestFixture +{ +public: + void testBasicString(); + + CPPUNIT_TEST_SUITE(SyntaxHighlightTest); + CPPUNIT_TEST(testBasicString); + CPPUNIT_TEST_SUITE_END(); +}; + +void SyntaxHighlightTest::testBasicString() +{ + OUString aBasicString(" if Mid(sText,iRun,1 )<> \" \" then Mid( sText ,iRun, 1, Chr( 1 + Asc( Mid(sText,iRun,1 )) ) '"); + + SyntaxHighlighter aHighlighter; + aHighlighter.initialize( HIGHLIGHT_BASIC ); + + std::vector<HighlightPortion> aPortions; + aHighlighter.getHighlightPortions( 0, aBasicString, aPortions ); + + + // check that all strings are valid + for(std::vector<HighlightPortion>::const_iterator itr = + aPortions.begin(), itrEnd = aPortions.end(); itr != itrEnd; ++itr) + { + CPPUNIT_ASSERT(itr->nBegin < aBasicString.getLength()); + //CPPUNIT_ASSERT(itr->nEnd < aBasicString.getLength()); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SyntaxHighlightTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |