Skip to content

Commit 26d59fc

Browse files
committed
Check coordinates are okay
1 parent 71434de commit 26d59fc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/axis.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
#include "axis.h"
22
#include "logAxis.h"
3+
#include <algorithm>
34
#include <gtest/gtest.h>
45

56
namespace UnitTest
67
{
78

8-
void matchAxes(Axis &axis, std::vector<double> &points)
9+
void matchAxes(Axis &axis, std::vector<double> &points, std::vector<double> &coords)
910
{
1011
axis.dataChanged();
1112
ASSERT_EQ(axis.tickCount(), points.size());
13+
ASSERT_EQ(axis.tickCount(), coords.size());
1214

1315
for (int i = 0; i < axis.tickCount(); i++)
1416
{
1517
EXPECT_DOUBLE_EQ(points[i], axis.tick(i));
18+
EXPECT_DOUBLE_EQ(coords[i], axis.tickCoord(i));
1619
}
1720
}
1821

@@ -23,8 +26,9 @@ TEST(AxisTest, LinearMarks)
2326
axis.setMaximum(11.0);
2427

2528
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};
2630

27-
matchAxes(axis, points);
31+
matchAxes(axis, points, coords);
2832
}
2933

3034
TEST(AxisTest, LogMarks)
@@ -34,8 +38,10 @@ TEST(AxisTest, LogMarks)
3438
axis.setMaximum(10.0);
3539

3640
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; });
3743

38-
matchAxes(axis, points);
44+
matchAxes(axis, points, coords);
3945
}
4046

4147
} // namespace UnitTest

0 commit comments

Comments
 (0)