summary refs log tree commit diff stats
path: root/Test/PanelExtractionTests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Test/PanelExtractionTests.cpp')
-rw-r--r--Test/PanelExtractionTests.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/Test/PanelExtractionTests.cpp b/Test/PanelExtractionTests.cpp new file mode 100644 index 0000000..dfb9b9e --- /dev/null +++ b/Test/PanelExtractionTests.cpp
@@ -0,0 +1,63 @@
1#include "gtest/gtest.h"
2#include "Panel.h"
3
4class PanelExtractionTests : public testing::Test
5{
6protected:
7 Panel _panel;
8 // std::shared_ptr<Panel> _panel;
9
10 void SetPanelSize(int width, int height) {
11 // _panel = std::make_shared<Panel>();
12 _panel._width = width;
13 _panel._height = height;
14 }
15
16 std::tuple<int, int> loc_to_xy(int location) {
17 return _panel.loc_to_xy(location);
18 }
19
20 int xy_to_loc(int x, int y) {
21 return _panel.xy_to_loc(x, y);
22 }
23};
24
25TEST_F(PanelExtractionTests, LocToXY_7x5) {
26 SetPanelSize(7, 5);
27 /* Here's the panel, with the correct location order
28 8 . 9 . 10. 11 (_width = 7)
29 . . . . . . .
30 4 . 5 . 6 . 7
31 . . . . . . .
32 0 . 1 . 2 . 3
33 (_height = 5)
34 */
35 ASSERT_EQ(0, xy_to_loc(0, 4));
36 ASSERT_EQ(1, xy_to_loc(2, 4));
37 ASSERT_EQ(2, xy_to_loc(4, 4));
38 ASSERT_EQ(3, xy_to_loc(6, 4));
39
40 ASSERT_EQ(4, xy_to_loc(0, 2));
41 ASSERT_EQ(5, xy_to_loc(2, 2));
42 ASSERT_EQ(6, xy_to_loc(4, 2));
43 ASSERT_EQ(7, xy_to_loc(6, 2));
44
45 ASSERT_EQ(8, xy_to_loc(0, 0));
46 ASSERT_EQ(9, xy_to_loc(2, 0));
47 ASSERT_EQ(10, xy_to_loc(4, 0));
48 ASSERT_EQ(11, xy_to_loc(6, 0));
49}
50
51TEST_F(PanelExtractionTests, LocToXY_3x3) {
52 SetPanelSize(3, 3);
53 /* Here's the panel, with the correct location order
54 2 . 3 (_width = 3)
55 . . .
56 0 . 1
57 (_height = 3)
58 */
59 ASSERT_EQ(0, xy_to_loc(0, 2));
60 ASSERT_EQ(1, xy_to_loc(2, 2));
61 ASSERT_EQ(2, xy_to_loc(0, 0));
62 ASSERT_EQ(3, xy_to_loc(2, 0));
63} \ No newline at end of file