Skip to content

Commit b43d3e2

Browse files
committed
Merge pull request #57 from Databean/addBackParameterizedTest
Adding back the parameterized test
2 parents 342e99b + df05d65 commit b43d3e2

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

tests/testRenderer.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
#include <iostream>
2+
#include <vector>
23

34
#include "gtest/gtest.h"
45

56
#include "Renderer.h"
67

8+
using std::vector;
79
using std::make_pair;
810

9-
TEST(RendererTest, coordToScreen) {
11+
class CoordinateConversionTest : public ::testing::TestWithParam<Coordinate> {
12+
13+
};
14+
15+
TEST_P(CoordinateConversionTest, IsReversable) {
16+
ASSERT_EQ(GetParam(), screenToCoord(coordToScreen(GetParam())));
17+
}
18+
19+
vector<Coordinate> makeInputs() {
20+
vector<Coordinate> ret;
1021
for(int x = -5; x < 5; x++) {
11-
for(auto y = -5; y < 5; y++) {
12-
auto original = make_pair(x, y);
13-
auto screen = coordToScreen(original);
14-
auto back = screenToCoord(screen);
15-
ASSERT_EQ(original.first, back.first);
16-
ASSERT_EQ(original.second, back.second);
22+
for(int y = -5; y < 5; y++) {
23+
ret.push_back(Coordinate{x, y});
1724
}
1825
}
26+
return std::move(ret);
1927
}
28+
29+
INSTANTIATE_TEST_CASE_P(LargeSquare, CoordinateConversionTest, ::testing::ValuesIn(makeInputs()));

0 commit comments

Comments
 (0)