Engauge Digitizer  2
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  const QStringList NO_LOAD_STARTUP_FILES;
25 
26  initializeLogging ("engauge_test",
27  "engauge_test.log",
28  DEBUG_FLAG);
29 
30  MainWindow w (NO_ERROR_REPORT_LOG_FILE,
31  NO_GNUPLOT_LOG_FILES,
32  NO_LOAD_STARTUP_FILES);
33  w.show ();
34 }
35 
36 void TestGraphCoords::testAnyColumnsRepeatNo ()
37 {
38  double m [3] [3];
39 
40  // No points repeat
41  m [0] [0] = 100;
42  m [1] [0] = 100;
43  m [2] [0] = 1;
44 
45  m [0] [1] = 300;
46  m [1] [1] = 100;
47  m [2] [1] = 1;
48 
49  m [0] [2] = 200;
50  m [1] [2] = 200;
51  m [2] [2] = 1;
52 
53  QVERIFY (!m_callback->anyColumnsRepeat (m, 3));
54 }
55 
56 void TestGraphCoords::testAnyColumnsRepeatYes ()
57 {
58  double m [3] [3];
59 
60  // First two points repeat
61  m [0] [0] = 100;
62  m [1] [0] = 100;
63  m [2] [0] = 1;
64 
65  m [0] [1] = 100;
66  m [1] [1] = 100;
67  m [2] [1] = 1;
68 
69  m [0] [2] = 200;
70  m [1] [2] = 200;
71  m [2] [2] = 1;
72 
73  QVERIFY (m_callback->anyColumnsRepeat (m, 3));
74 }
75 
76 void TestGraphCoords::testThreeCollinearPointsNo ()
77 {
78  double m [3] [3];
79 
80  // Points are not collinear
81  m [0] [0] = 100;
82  m [1] [0] = 100;
83  m [2] [0] = 1;
84 
85  m [0] [1] = 300;
86  m [1] [1] = 150;
87  m [2] [1] = 1;
88 
89  m [0] [2] = 200;
90  m [1] [2] = 200;
91  m [2] [2] = 1;
92 
93  QVERIFY (!m_callback->threePointsAreCollinear (m, 3));
94 }
95 
96 void TestGraphCoords::testThreeCollinearPointsYes ()
97 {
98  double m [3] [3];
99 
100  // Points are collinear
101  m [0] [0] = 100;
102  m [1] [0] = 100;
103  m [2] [0] = 1;
104 
105  m [0] [1] = 150;
106  m [1] [1] = 150;
107  m [2] [1] = 1;
108 
109  m [0] [2] = 200;
110  m [1] [2] = 200;
111  m [2] [2] = 1;
112 
113  QVERIFY (m_callback->threePointsAreCollinear (m, 3));
114 }
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:66