From eb13f2d92ca7a1688a5b7849b58e0e36f16fe557 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 23 Oct 2013 04:26:39 +0200 Subject: add inital test for syntaxhighlighter Test is partly disabled as we still generate invalid tokens Change-Id: I1a9b03b9bbe2ed7087c6ab7b6d0823ac1d058ba7 --- .../CppunitTest_comphelper_syntaxhighlight_test.mk | 29 ++++++++++++ comphelper/qa/unit/syntaxhighlighttest.cxx | 53 ++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 comphelper/CppunitTest_comphelper_syntaxhighlight_test.mk create mode 100644 comphelper/qa/unit/syntaxhighlighttest.cxx (limited to 'comphelper') 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 +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" +#include "rtl/ustring.hxx" + +#include + +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 aPortions; + aHighlighter.getHighlightPortions( 0, aBasicString, aPortions ); + + + // check that all strings are valid + for(std::vector::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: */ -- cgit v1.2.3