Changeset View
Changeset View
Standalone View
Standalone View
tests/spreadsheet/TrivialTest.cpp
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | File : TrivialTest.cpp | ||||
3 | Project : LabPlot | ||||
4 | Description : Tests for the Spreadsheet's trivial features | ||||
5 | -------------------------------------------------------------------- | ||||
6 | Copyright : (C) 2019 Shubham (aryan100jangid@gmail.com) | ||||
7 | ***************************************************************************/ | ||||
8 | | ||||
9 | /*************************************************************************** | ||||
10 | * * | ||||
11 | * This program is free software; you can redistribute it and/or modify * | ||||
12 | * it under the terms of the GNU General Public License as published by * | ||||
13 | * the Free Software Foundation; either version 2 of the License, or * | ||||
14 | * (at your option) any later version. * | ||||
15 | * * | ||||
16 | * This program is distributed in the hope that it will be useful, * | ||||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
19 | * GNU General Public License for more details. * | ||||
20 | * * | ||||
21 | * You should have received a copy of the GNU General Public License * | ||||
22 | * along with this program; if not, write to the Free Software * | ||||
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, * | ||||
24 | * Boston, MA 02110-1301 USA * | ||||
25 | * * | ||||
26 | ***************************************************************************/ | ||||
27 | | ||||
28 | #include "TrivialTest.h" | ||||
29 | | ||||
30 | TrivialTest::TrivialTest() { | ||||
31 | sheet = new Spreadsheet("test", false); | ||||
32 | | ||||
33 | sheet->column(0)->setValueAt(0, 10.0); | ||||
34 | sheet->column(0)->setValueAt(1, 20.0); | ||||
35 | sheet->column(0)->setValueAt(2, 30.0); | ||||
36 | | ||||
37 | sheet->column(1)->setValueAt(0, 100.0); | ||||
38 | sheet->column(1)->setValueAt(1, 200.0); | ||||
39 | sheet->column(1)->setValueAt(2, 300.0); | ||||
40 | | ||||
41 | sheet->column(2)->setValueAt(0, 1000.0); | ||||
42 | sheet->column(2)->setValueAt(1, 2000.0); | ||||
43 | sheet->column(2)->setValueAt(2, 3000.0); | ||||
44 | } | ||||
45 | | ||||
46 | TrivialTest::~TrivialTest() { | ||||
47 | delete sheet; | ||||
48 | } | ||||
49 | | ||||
50 | void TrivialTest::testRowCount() { | ||||
51 | QCOMPARE(sheet->rowCount(), 3); | ||||
52 | } | ||||
53 | | ||||
54 | void TrivialTest::testColumnCount() { | ||||
55 | QCOMPARE(sheet->columnCount(), 3); | ||||
56 | } | ||||
57 | | ||||
58 | void TrivialTest::testRowColumnValues() { | ||||
59 | QCOMPARE(sheet->column(0)->valueAt(0), 10.0); | ||||
60 | QCOMPARE(sheet->column(0)->valueAt(1), 20.0); | ||||
61 | QCOMPARE(sheet->column(2)->valueAt(1), 2000.0); | ||||
62 | QCOMPARE(sheet->column(2)->valueAt(0), 1000.0); | ||||
63 | } | ||||
64 | | ||||
65 | void TrivialTest::testAddRemoveRow() { | ||||
66 | // Test adding a row | ||||
67 | QCOMPARE(sheet->rowCount(), 3); | ||||
68 | sheet->insertRows(3, 1); | ||||
69 | QCOMPARE(sheet->rowCount(), 4); | ||||
70 | | ||||
71 | // Test removing a row | ||||
72 | sheet->removeRows(3, 1); | ||||
73 | QCOMPARE(sheet->rowCount(), 3); | ||||
74 | } | ||||
75 | | ||||
76 | void TrivialTest::testAddRemoveColumn() { | ||||
77 | // Test adding a column | ||||
78 | QCOMPARE(sheet->columnCount(), 3); | ||||
79 | sheet->insertColumns(3, 1); | ||||
80 | QCOMPARE(sheet->columnCount(), 4); | ||||
81 | | ||||
82 | // Test removing a column | ||||
83 | sheet->removeColumns(3, 1); | ||||
84 | QCOMPARE(sheet->columnCount(), 3); | ||||
85 | } | ||||
86 | | ||||
87 | QTEST_MAIN(TrivialTest) |