From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- svx/qa/unit/removewhichrange.cxx | 122 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 svx/qa/unit/removewhichrange.cxx (limited to 'svx/qa/unit/removewhichrange.cxx') diff --git a/svx/qa/unit/removewhichrange.cxx b/svx/qa/unit/removewhichrange.cxx new file mode 100644 index 000000000..d5856f6c7 --- /dev/null +++ b/svx/qa/unit/removewhichrange.cxx @@ -0,0 +1,122 @@ +/* -*- 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 + +#include +#include +#include +#include + +#include +#include + +namespace +{ +class TestRemoveWhichRange : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(TestRemoveWhichRange); + CPPUNIT_TEST(testRemoveWhichRange); + CPPUNIT_TEST_SUITE_END(); + + void testRemoveWhichRange() + { + { + WhichRangesContainer in; + auto const out = RemoveWhichRange(in, 10, 20); + CPPUNIT_ASSERT(out.empty()); + } + { + WhichRangesContainer in(svl::Items<10, 20, 30, 40>); + auto const out = RemoveWhichRange(in, 0, 20); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[0].second); + } + { + WhichRangesContainer in(svl::Items<10, 20, 30, 40>); + auto const out = RemoveWhichRange(in, 10, 20); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[0].second); + } + { + WhichRangesContainer in(svl::Items<10, 20, 30, 40>); + auto const out = RemoveWhichRange(in, 15, 20); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[0].second); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[1].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].second); + } + { + WhichRangesContainer in(svl::Items<10, 20, 30, 40>); + auto const out = RemoveWhichRange(in, 30, 40); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second); + } + { + WhichRangesContainer in(svl::Items<10, 20, 30, 40>); + auto const out = RemoveWhichRange(in, 30, 50); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second); + } + { + WhichRangesContainer in(svl::Items<10, 20, 30, 40>); + auto const out = RemoveWhichRange(in, 30, 35); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[1].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].second); + } + { + WhichRangesContainer in(svl::Items<10, 20, 30, 40>); + auto const out = RemoveWhichRange(in, 15, 35); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[0].second); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[1].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].second); + } + { + WhichRangesContainer in(svl::Items<10, 20, 30, 40>); + auto const out = RemoveWhichRange(in, 12, 15); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(11), out[0].second); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(16), out[1].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1].second); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[2].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[2].second); + } + { + WhichRangesContainer in(svl::Items<10, 20, 30, 40>); + auto const out = RemoveWhichRange(in, 0, 100); + CPPUNIT_ASSERT(out.empty()); + } + { + WhichRangesContainer in(svl::Items<10, 20, 40, 50>); + auto const out = RemoveWhichRange(in, 25, 35); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(50), out[1].second); + } + { + WhichRangesContainer in(svl::Items<10, 20, 40, 50>); + auto const out = RemoveWhichRange(in, 50, 100); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].first); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(49), out[1].second); + } + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(TestRemoveWhichRange); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit v1.2.3