Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
TestGraphCoords.cpp
1 #include "CallbackUpdateTransform.h"
2 #include "Logger.h"
3 #include "MainWindow.h"
4 #include <QtTest/QtTest>
5 #include "Test/TestGraphCoords.h"
6 
7 QTEST_MAIN (TestGraphCoords)
8 
9 TestGraphCoords::TestGraphCoords(QObject *parent) :
10  QObject(parent)
11 {
12  m_callback = new CallbackUpdateTransform (m_modelCoords);
13 }
14 
15 void TestGraphCoords::cleanupTestCase ()
16 {
17 }
18 
19 void TestGraphCoords::initTestCase ()
20 {
21  const QString NO_ERROR_REPORT_LOG_FILE;
22  const bool NO_GNUPLOT_LOG_FILES = false;
23  const bool DEBUG_FLAG = false;
24 
25  initializeLogging ("engauge_test",
26  "engauge_test.log",
27  DEBUG_FLAG);
28 
29  MainWindow w (NO_ERROR_REPORT_LOG_FILE,
30  NO_GNUPLOT_LOG_FILES);
31  w.show ();
32 }
33 
34 void TestGraphCoords::testAnyColumnsRepeatNo ()
35 {
36  double m [3] [3];
37 
38  // No points repeat
39  m [0] [0] = 100;
40  m [1] [0] = 100;
41  m [2] [0] = 1;
42 
43  m [0] [1] = 300;
44  m [1] [1] = 100;
45  m [2] [1] = 1;
46 
47  m [0] [2] = 200;
48  m [1] [2] = 200;
49  m [2] [2] = 1;
50 
51  QVERIFY (!m_callback->anyColumnsRepeat (m, 3));
52 }
53 
54 void TestGraphCoords::testAnyColumnsRepeatYes ()
55 {
56  double m [3] [3];
57 
58  // First two points repeat
59  m [0] [0] = 100;
60  m [1] [0] = 100;
61  m [2] [0] = 1;
62 
63  m [0] [1] = 100;
64  m [1] [1] = 100;
65  m [2] [1] = 1;
66 
67  m [0] [2] = 200;
68  m [1] [2] = 200;
69  m [2] [2] = 1;
70 
71  QVERIFY (m_callback->anyColumnsRepeat (m, 3));
72 }
73 
74 void TestGraphCoords::testThreeCollinearPointsNo ()
75 {
76  double m [3] [3];
77 
78  // Points are not collinear
79  m [0] [0] = 100;
80  m [1] [0] = 100;
81  m [2] [0] = 1;
82 
83  m [0] [1] = 300;
84  m [1] [1] = 150;
85  m [2] [1] = 1;
86 
87  m [0] [2] = 200;
88  m [1] [2] = 200;
89  m [2] [2] = 1;
90 
91  QVERIFY (!m_callback->threePointsAreCollinear (m, 3));
92 }
93 
94 void TestGraphCoords::testThreeCollinearPointsYes ()
95 {
96  double m [3] [3];
97 
98  // Points are collinear
99  m [0] [0] = 100;
100  m [1] [0] = 100;
101  m [2] [0] = 1;
102 
103  m [0] [1] = 150;
104  m [1] [1] = 150;
105  m [2] [1] = 1;
106 
107  m [0] [2] = 200;
108  m [1] [2] = 200;
109  m [2] [2] = 1;
110 
111  QVERIFY (m_callback->threePointsAreCollinear (m, 3));
112 }
Callback for collecting axis points and then calculating the current transform from those axis points...
Unit tests of graph coordinate sanity checking.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:60