[Libreoffice-commits] core.git: svl/CppunitTest_svl_adrparse.mk svl/Module_svl.mk svl/qa
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 9 15:02:11 UTC 2021
svl/CppunitTest_svl_adrparse.mk | 21 +++++++++
svl/Module_svl.mk | 1
svl/qa/unit/test_SvAddressParser.cxx | 77 +++++++++++++++++++++++++++++++++++
3 files changed, 99 insertions(+)
New commits:
commit acf565ea13204479f215ca597a432d69dac4290d
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Jun 9 15:33:04 2021 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Jun 9 17:01:19 2021 +0200
Add an SvAddressParser unit test
Change-Id: I7d08528f455bb7849e0b62da16c5387b1812ccb9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116919
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/svl/CppunitTest_svl_adrparse.mk b/svl/CppunitTest_svl_adrparse.mk
new file mode 100644
index 000000000000..7cd663c8e217
--- /dev/null
+++ b/svl/CppunitTest_svl_adrparse.mk
@@ -0,0 +1,21 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*-
+#
+# 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,svl_adrparse))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,svl_adrparse, \
+ svl/qa/unit/test_SvAddressParser \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,svl_adrparse, \
+ sal \
+ svl \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/svl/Module_svl.mk b/svl/Module_svl.mk
index 6283df82eadb..45bf74915c14 100644
--- a/svl/Module_svl.mk
+++ b/svl/Module_svl.mk
@@ -30,6 +30,7 @@ $(eval $(call gb_Module_add_l10n_targets,svl,\
))
$(eval $(call gb_Module_add_check_targets,svl,\
+ CppunitTest_svl_adrparse \
CppunitTest_svl_inetcontenttype \
CppunitTest_svl_itempool \
CppunitTest_svl_items \
diff --git a/svl/qa/unit/test_SvAddressParser.cxx b/svl/qa/unit/test_SvAddressParser.cxx
new file mode 100644
index 000000000000..b015f9a1b389
--- /dev/null
+++ b/svl/qa/unit/test_SvAddressParser.cxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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 <sal/config.h>
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <sal/types.h>
+#include <svl/adrparse.hxx>
+
+namespace
+{
+class Test : public CppUnit::TestFixture
+{
+ void testRfc822ExampleAddresses()
+ {
+ // Examples taken from section A.1 "Examples: Addresses" of
+ // <https://tools.ietf.org/html/rfc822> "Standard for the Format of ARPA Internet Text
+ // Messages":
+ {
+ SvAddressParser p("Alfred Neuman <Neuman at BBN-TENEXA>");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), p.Count());
+ CPPUNIT_ASSERT_EQUAL(OUString("Neuman at BBN-TENEXA"), p.GetEmailAddress(0));
+ }
+ {
+ SvAddressParser p("Neuman at BBN-TENEXA");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), p.Count());
+ CPPUNIT_ASSERT_EQUAL(OUString("Neuman at BBN-TENEXA"), p.GetEmailAddress(0));
+ }
+ {
+ SvAddressParser p("\"George, Ted\" <Shared at Group.Arpanet>");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), p.Count());
+ CPPUNIT_ASSERT_EQUAL(OUString("Shared at Group.Arpanet"), p.GetEmailAddress(0));
+ }
+ {
+ SvAddressParser p("Wilt . (the Stilt) Chamberlain at NBA.US");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), p.Count());
+ CPPUNIT_ASSERT_EQUAL(OUString("Wilt.Chamberlain at NBA.US"), p.GetEmailAddress(0));
+ }
+ {
+ SvAddressParser p("Gourmets: Pompous Person <WhoZiWhatZit at Cordon-Bleu>,\n"
+ " Childs at WGBH.Boston, Galloping Gourmet@\n"
+ " ANT.Down-Under (Australian National Television),\n"
+ " Cheapie at Discount-Liquors;,\n"
+ " Cruisers: Port at Portugal, Jones at SEA;,\n"
+ " Another at Somewhere.SomeOrg");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(7), p.Count());
+ CPPUNIT_ASSERT_EQUAL(OUString("WhoZiWhatZit at Cordon-Bleu"), p.GetEmailAddress(0));
+ CPPUNIT_ASSERT_EQUAL(OUString("Childs at WGBH.Boston"), p.GetEmailAddress(1));
+ CPPUNIT_ASSERT_EQUAL(OUString("Gourmet at ANT.Down-Under"), p.GetEmailAddress(2));
+ CPPUNIT_ASSERT_EQUAL(OUString("Cheapie at Discount-Liquors"), p.GetEmailAddress(3));
+ CPPUNIT_ASSERT_EQUAL(OUString("Port at Portugal"), p.GetEmailAddress(4));
+ CPPUNIT_ASSERT_EQUAL(OUString("Jones at SEA"), p.GetEmailAddress(5));
+ CPPUNIT_ASSERT_EQUAL(OUString("Another at Somewhere.SomeOrg"), p.GetEmailAddress(6));
+ }
+ }
+
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(testRfc822ExampleAddresses);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
More information about the Libreoffice-commits
mailing list