File indexing completed on 2024-05-12 16:35:54
0001 /* This file is part of the KDE project 0002 Copyright 2011 Marijn Kruisselbrink <mkruisselbrink@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "TestCellStorage.h" 0021 0022 #include <sheets/CellStorage.h> 0023 #include <sheets/Map.h> 0024 #include <sheets/Sheet.h> 0025 #include <sheets/Value.h> 0026 0027 #include <QTest> 0028 0029 using namespace Calligra::Sheets; 0030 0031 void CellStorageTest::testMergedCellsInsertRowBug() 0032 { 0033 Map map; 0034 Sheet* sheet = map.addNewSheet(); 0035 CellStorage* storage = sheet->cellStorage(); 0036 0037 // | 1 | 4 | 0038 // |-------| 0039 // | 2 | 0040 // |-------| 0041 // | | 5 | 0042 // | 3 |---| 0043 // | | 6 | 0044 // |-------| 0045 // | 7 | 8 | 0046 storage->setValue(1, 1, Value(1)); 0047 storage->setValue(2, 1, Value(4)); 0048 storage->setValue(1, 2, Value(2)); 0049 storage->setValue(1, 3, Value(3)); 0050 storage->setValue(2, 3, Value(5)); 0051 storage->setValue(2, 4, Value(6)); 0052 storage->setValue(1, 5, Value(7)); 0053 storage->setValue(2, 5, Value(8)); 0054 storage->mergeCells(1, 2, 2, 1); 0055 storage->mergeCells(1, 3, 1, 2); 0056 0057 // insert a row 0058 storage->insertRows(5, 1); 0059 0060 // validate result 0061 QCOMPARE(storage->value(1, 1), Value(1)); 0062 QCOMPARE(storage->value(2, 1), Value(4)); 0063 QCOMPARE(storage->value(1, 2), Value(2)); 0064 QCOMPARE(storage->value(1, 3), Value(3)); 0065 QCOMPARE(storage->value(2, 3), Value(5)); 0066 QCOMPARE(storage->value(2, 4), Value(6)); 0067 QCOMPARE(storage->value(1, 6), Value(7)); 0068 QCOMPARE(storage->value(2, 6), Value(8)); 0069 QCOMPARE(storage->mergedXCells(1, 2), 2); 0070 QCOMPARE(storage->mergedYCells(1, 2), 1); 0071 QCOMPARE(storage->mergedXCells(1, 3), 1); 0072 QCOMPARE(storage->mergedYCells(1, 3), 2); 0073 } 0074 0075 QTEST_MAIN(CellStorageTest)