1
1
#include " axis.h"
2
2
#include " logAxis.h"
3
+ #include < algorithm>
3
4
#include < gtest/gtest.h>
4
5
5
6
namespace UnitTest
6
7
{
7
8
8
- void matchAxes (Axis &axis, std::vector<double > &points)
9
+ void matchAxes (Axis &axis, std::vector<double > &points, std::vector< double > &coords )
9
10
{
10
11
axis.dataChanged ();
11
12
ASSERT_EQ (axis.tickCount (), points.size ());
13
+ ASSERT_EQ (axis.tickCount (), coords.size ());
12
14
13
15
for (int i = 0 ; i < axis.tickCount (); i++)
14
16
{
15
17
EXPECT_DOUBLE_EQ (points[i], axis.tick (i));
18
+ EXPECT_DOUBLE_EQ (coords[i], axis.tickCoord (i));
16
19
}
17
20
}
18
21
@@ -23,8 +26,9 @@ TEST(AxisTest, LinearMarks)
23
26
axis.setMaximum (11.0 );
24
27
25
28
std::vector<double > points = {-10 , -5 , 0 , 5 , 10 };
29
+ std::vector<double > coords = {1.0 / 11.0 , 6.0 / 11.0 , 1.0 , 16.0 / 11.0 , 21.0 / 11.0 };
26
30
27
- matchAxes (axis, points);
31
+ matchAxes (axis, points, coords );
28
32
}
29
33
30
34
TEST (AxisTest, LogMarks)
@@ -34,8 +38,10 @@ TEST(AxisTest, LogMarks)
34
38
axis.setMaximum (10.0 );
35
39
36
40
std::vector<double > points = {0.1 , 0.2 , 0.3 , 0.5 , 0.8 , 1.0 , 2.0 , 3.0 , 5.0 , 8.0 , 10.0 };
41
+ std::vector<double > coords (points.size ());
42
+ std::transform (points.begin (), points.end (), coords.begin (), [](const auto x) { return log10 (x) + 1.0 ; });
37
43
38
- matchAxes (axis, points);
44
+ matchAxes (axis, points, coords );
39
45
}
40
46
41
47
} // namespace UnitTest
0 commit comments