-
Notifications
You must be signed in to change notification settings - Fork 2
/
ApprovalsQtTests.cpp
49 lines (45 loc) · 1.4 KB
/
ApprovalsQtTests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <catch2/catch.hpp>
#include <QImage>
#include <QTableWidget>
#include <utility>
#include "ApprovalTestsQt/ApprovalsQt.h"
namespace
{
void populateTable(QTableWidget& tableWidget)
{
const int rows = 2;
const int columns = 3;
tableWidget.setRowCount(rows);
tableWidget.setColumnCount(columns);
tableWidget.setHorizontalHeaderLabels(QStringList() << "Column 1"
<< "Column 2"
<< "Column 3");
for (int i = 0; i != rows; ++i)
{
for (int j = 0; j != columns; ++j)
{
tableWidget.setItem(
i, j, new QTableWidgetItem(QString::number((i + 1) * (j + 1))));
}
}
}
} // namespace
TEST_CASE("It approves a QImage")
{
// begin-snippet: verify_qimage
QImage image(10, 20, QImage::Format_RGB32);
image.fill(Qt::red);
ApprovalTestsQt::verifyQImage(image);
// end-snippet
}
TEST_CASE("It approves a QTableWidget")
{
// A note on naming: QTableWidget is a concrete class that implements
// the more general QTableView. Here we create a QTableWidget,
// for convenience.
// begin-snippet: verify_table_view
QTableWidget tableWidget;
populateTable(tableWidget);
ApprovalTestsQt::verifyQTableView(tableWidget);
// end-snippet
}