Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / qa / unit / removewhichrange.cxx
blobd5856f6c70e90975c4d92328170261fe4b671cfb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/config.h>
12 #include <cppunit/TestAssert.h>
13 #include <cppunit/TestFixture.h>
14 #include <cppunit/extensions/HelperMacros.h>
15 #include <cppunit/plugin/TestPlugIn.h>
17 #include <sal/types.h>
18 #include <svx/svdetc.hxx>
20 namespace
22 class TestRemoveWhichRange : public CppUnit::TestFixture
24 CPPUNIT_TEST_SUITE(TestRemoveWhichRange);
25 CPPUNIT_TEST(testRemoveWhichRange);
26 CPPUNIT_TEST_SUITE_END();
28 void testRemoveWhichRange()
31 WhichRangesContainer in;
32 auto const out = RemoveWhichRange(in, 10, 20);
33 CPPUNIT_ASSERT(out.empty());
36 WhichRangesContainer in(svl::Items<10, 20, 30, 40>);
37 auto const out = RemoveWhichRange(in, 0, 20);
38 CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0].first);
39 CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[0].second);
42 WhichRangesContainer in(svl::Items<10, 20, 30, 40>);
43 auto const out = RemoveWhichRange(in, 10, 20);
44 CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0].first);
45 CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[0].second);
48 WhichRangesContainer in(svl::Items<10, 20, 30, 40>);
49 auto const out = RemoveWhichRange(in, 15, 20);
50 CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
51 CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[0].second);
52 CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[1].first);
53 CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].second);
56 WhichRangesContainer in(svl::Items<10, 20, 30, 40>);
57 auto const out = RemoveWhichRange(in, 30, 40);
58 CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
59 CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
62 WhichRangesContainer in(svl::Items<10, 20, 30, 40>);
63 auto const out = RemoveWhichRange(in, 30, 50);
64 CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
65 CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
68 WhichRangesContainer in(svl::Items<10, 20, 30, 40>);
69 auto const out = RemoveWhichRange(in, 30, 35);
70 CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
71 CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
72 CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[1].first);
73 CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].second);
76 WhichRangesContainer in(svl::Items<10, 20, 30, 40>);
77 auto const out = RemoveWhichRange(in, 15, 35);
78 CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
79 CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[0].second);
80 CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[1].first);
81 CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].second);
84 WhichRangesContainer in(svl::Items<10, 20, 30, 40>);
85 auto const out = RemoveWhichRange(in, 12, 15);
86 CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
87 CPPUNIT_ASSERT_EQUAL(sal_uInt16(11), out[0].second);
88 CPPUNIT_ASSERT_EQUAL(sal_uInt16(16), out[1].first);
89 CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1].second);
90 CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[2].first);
91 CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[2].second);
94 WhichRangesContainer in(svl::Items<10, 20, 30, 40>);
95 auto const out = RemoveWhichRange(in, 0, 100);
96 CPPUNIT_ASSERT(out.empty());
99 WhichRangesContainer in(svl::Items<10, 20, 40, 50>);
100 auto const out = RemoveWhichRange(in, 25, 35);
101 CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
102 CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
103 CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].first);
104 CPPUNIT_ASSERT_EQUAL(sal_uInt16(50), out[1].second);
107 WhichRangesContainer in(svl::Items<10, 20, 40, 50>);
108 auto const out = RemoveWhichRange(in, 50, 100);
109 CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
110 CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
111 CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].first);
112 CPPUNIT_ASSERT_EQUAL(sal_uInt16(49), out[1].second);
117 CPPUNIT_TEST_SUITE_REGISTRATION(TestRemoveWhichRange);
120 CPPUNIT_PLUGIN_IMPLEMENT();
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */