[Libreoffice-commits] core.git: comphelper/CppunitTest_comphelper_syntaxhighlight_test.mk comphelper/qa
Markus Mohrhard
markus.mohrhard at googlemail.com
Tue Oct 22 19:28:40 PDT 2013
comphelper/CppunitTest_comphelper_syntaxhighlight_test.mk | 29 +++++++
comphelper/qa/unit/syntaxhighlighttest.cxx | 53 ++++++++++++++
2 files changed, 82 insertions(+)
New commits:
commit eb13f2d92ca7a1688a5b7849b58e0e36f16fe557
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Oct 23 04:26:39 2013 +0200
add inital test for syntaxhighlighter
Test is partly disabled as we still generate invalid tokens
Change-Id: I1a9b03b9bbe2ed7087c6ab7b6d0823ac1d058ba7
diff --git a/comphelper/CppunitTest_comphelper_syntaxhighlight_test.mk b/comphelper/CppunitTest_comphelper_syntaxhighlight_test.mk
new file mode 100644
index 0000000..3c9960c
--- /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 0000000..244a1a0
--- /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: */
More information about the Libreoffice-commits
mailing list