Qt 5.10 Book Examples
test.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // test.cpp
3 // ======================================================================
4 // This file is a part of the book
5 // "Qt 5.10 Professional programming with C++"
6 // http://qt-book.com
7 // ======================================================================
8 // Copyright (c) 2017 by Max Schlee
9 // ======================================================================
10 
11 #include <QtTest>
12 #include "MyClass.h"
13 
14 // ======================================================================
15 class Test_MyClass : public QObject {
16 Q_OBJECT
17 private slots:
18  void min();
19  void max();
20 };
21 
22 // ----------------------------------------------------------------------
23 void Test_MyClass::min()
24 {
25  MyClass myClass;
26  QCOMPARE(myClass.min(25, 0), 0);
27  QCOMPARE(myClass.min(-12, -5), -12);
28  QCOMPARE(myClass.min(2007, 2007), 2007);
29  QCOMPARE(myClass.min(-12, 5), -12);
30 }
31 
32 // ----------------------------------------------------------------------
33 void Test_MyClass::max()
34 {
35  MyClass myClass;
36  QCOMPARE(myClass.max(25, 0), 25);
37  QCOMPARE(myClass.max(-12, -5), -5);
38  QCOMPARE(myClass.max(2007, 2007), 2007);
39  QCOMPARE(myClass.max(-12, 5), 5);
40 }
41 
42 QTEST_MAIN(Test_MyClass)
43 #include "test.moc"
int max(int n1, int n2)
Definition: MyClass.h:21
int min(int n1, int n2)
Definition: MyClass.h:16