File indexing completed on 2024-12-22 04:10:15
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kis_fill_interval_map_test.h" 0008 0009 #include <simpletest.h> 0010 0011 #include <floodfill/kis_fill_interval_map.h> 0012 #include <floodfill/kis_fill_interval_map_p.h> 0013 0014 void KisFillIntervalMapTest::test() 0015 { 0016 const int row = 1; 0017 0018 KisFillInterval i1( 0, 40, row); 0019 KisFillInterval i2(11, 40, row); 0020 KisFillInterval i3(11, 19, row); 0021 KisFillInterval i4(11, 20, row); 0022 0023 KisFillIntervalMap map; 0024 0025 // 0..10, 20..30, 40..50, ... 0026 for (int i = 0; i < 100; i += 20) { 0027 map.insertInterval(KisFillInterval(i, i + 10, row)); 0028 } 0029 0030 KisFillIntervalMap::Private::IteratorRange range; 0031 0032 range = map.m_d->findFirstIntersectingInterval(i1); 0033 QCOMPARE(range.beginIt->start, 0); 0034 QCOMPARE(range.beginIt->end, 10); 0035 0036 range = map.m_d->findFirstIntersectingInterval(i2); 0037 QCOMPARE(range.beginIt->start, 20); 0038 QCOMPARE(range.beginIt->end, 30); 0039 0040 range = map.m_d->findFirstIntersectingInterval(i3); 0041 QCOMPARE(range.beginIt, range.endIt); 0042 0043 range = map.m_d->findFirstIntersectingInterval(i4); 0044 QCOMPARE(range.beginIt->start, 20); 0045 QCOMPARE(range.beginIt->end, 30); 0046 } 0047 0048 SIMPLE_TEST_MAIN(KisFillIntervalMapTest)