svx/CppunitTest_svx_removewhichrange.mk |   61 ++++++++++++++
 svx/Module_svx.mk                       |    1 
 svx/qa/unit/removewhichrange.cxx        |  132 ++++++++++++++++++++++++++++++++
 3 files changed, 194 insertions(+)

New commits:
commit a07339b108275dde1769f86404515b0f19e98f2d
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Thu Jun 17 14:20:00 2021 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Thu Jun 17 23:00:34 2021 +0200

    Add RemoveWhichRange unit test
    
    ...following up on the TODO in the commit message of
    541f94df85756d3a383b1f9ba49841ca0011b52e "memcpy-param-overlap"
    
    Change-Id: Ib1f73b867eb3625e66a5040122e53a4a6e486802
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117385
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/svx/CppunitTest_svx_removewhichrange.mk 
b/svx/CppunitTest_svx_removewhichrange.mk
new file mode 100644
index 000000000000..95f958a39e5f
--- /dev/null
+++ b/svx/CppunitTest_svx_removewhichrange.mk
@@ -0,0 +1,61 @@
+# -*- 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,svx_removewhichrange))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,svx_removewhichrange, \
+    svx/qa/unit/removewhichrange \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,svx_removewhichrange, \
+    boost_headers \
+    libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,svx_removewhichrange, \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    drawinglayer \
+    editeng \
+    fwk \
+    i18nlangtag \
+    i18nutil \
+    sal \
+    salhelper \
+    sax \
+    sb \
+    sfx \
+    sot \
+    svl \
+    svt \
+    tk \
+    tl \
+    ucbhelper \
+    utl \
+    vcl \
+    xo \
+    $(call gb_Helper_optional,AVMEDIA,avmedia) \
+    $(call gb_Helper_optional,DBCONNECTIVITY,dbtools) \
+))
+
+$(eval $(call gb_CppunitTest_use_library_objects,svx_removewhichrange, \
+    svxcore \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,svx_removewhichrange))
+
+ifeq ($(OS),MACOSX)
+$(eval $(call 
gb_CppunitTest_use_system_darwin_frameworks,svx_removewhichrange, \
+    Foundation \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/svx/Module_svx.mk b/svx/Module_svx.mk
index 9a45df4943c1..3891829c8108 100644
--- a/svx/Module_svx.mk
+++ b/svx/Module_svx.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_Module_add_l10n_targets,svx,\
 $(eval $(call gb_Module_add_check_targets,svx,\
        CppunitTest_svx_unit \
        CppunitTest_svx_gallery_test \
+       CppunitTest_svx_removewhichrange \
 ))
 
 # screenshots
diff --git a/svx/qa/unit/removewhichrange.cxx b/svx/qa/unit/removewhichrange.cxx
new file mode 100644
index 000000000000..fc2b0a038931
--- /dev/null
+++ b/svx/qa/unit/removewhichrange.cxx
@@ -0,0 +1,132 @@
+/* -*- 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 <svx/svdetc.hxx>
+
+namespace
+{
+class TestRemoveWhichRange : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE(TestRemoveWhichRange);
+    CPPUNIT_TEST(testRemoveWhichRange);
+    CPPUNIT_TEST_SUITE_END();
+
+    void testRemoveWhichRange()
+    {
+        {
+            sal_uInt16 const in[] = { 0 };
+            auto const out = RemoveWhichRange(in, 10, 20);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[0]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+            auto const out = RemoveWhichRange(in, 0, 20);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[2]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+            auto const out = RemoveWhichRange(in, 10, 20);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[2]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+            auto const out = RemoveWhichRange(in, 15, 20);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[2]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[3]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+            auto const out = RemoveWhichRange(in, 30, 40);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[2]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+            auto const out = RemoveWhichRange(in, 30, 50);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[2]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+            auto const out = RemoveWhichRange(in, 30, 35);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[2]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[3]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+            auto const out = RemoveWhichRange(in, 15, 35);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[2]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[3]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+            auto const out = RemoveWhichRange(in, 12, 15);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(11), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(16), out[2]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[3]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[4]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[5]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[6]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+            auto const out = RemoveWhichRange(in, 0, 100);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[0]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 40, 50, 0 };
+            auto const out = RemoveWhichRange(in, 25, 35);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[2]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(50), out[3]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+        }
+        {
+            sal_uInt16 const in[] = { 10, 20, 40, 50, 0 };
+            auto const out = RemoveWhichRange(in, 50, 100);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[2]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(49), out[3]);
+            CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+        }
+    }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TestRemoveWhichRange);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to