about summary refs log tree commit diff stats
path: root/Test/PanelExtractionTests.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-11-09 10:08:03 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2018-11-09 10:08:03 -0800
commit1f85741c8d12d9b1fbd55b29f334de572f9eea9b (patch)
tree098ec2630e40ed9f0a2fabf11f49f05111653bde /Test/PanelExtractionTests.cpp
parentc388759ed67b792201b99bf7d73d036c34b47d87 (diff)
downloadwitness-tutorializer-1f85741c8d12d9b1fbd55b29f334de572f9eea9b.tar.gz
witness-tutorializer-1f85741c8d12d9b1fbd55b29f334de572f9eea9b.tar.bz2
witness-tutorializer-1f85741c8d12d9b1fbd55b29f334de572f9eea9b.zip
Reading & writing to tutorial vault works!
Diffstat (limited to 'Test/PanelExtractionTests.cpp')
-rw-r--r--Test/PanelExtractionTests.cpp119
1 files changed, 92 insertions, 27 deletions
diff --git a/Test/PanelExtractionTests.cpp b/Test/PanelExtractionTests.cpp index dfb9b9e..099fab2 100644 --- a/Test/PanelExtractionTests.cpp +++ b/Test/PanelExtractionTests.cpp
@@ -4,7 +4,8 @@
4class PanelExtractionTests : public testing::Test 4class PanelExtractionTests : public testing::Test
5{ 5{
6protected: 6protected:
7 Panel _panel; 7 // Test constructor, does not attach to process
8 Panel _panel = Panel();
8 // std::shared_ptr<Panel> _panel; 9 // std::shared_ptr<Panel> _panel;
9 10
10 void SetPanelSize(int width, int height) { 11 void SetPanelSize(int width, int height) {
@@ -13,22 +14,88 @@ protected:
13 _panel._height = height; 14 _panel._height = height;
14 } 15 }
15 16
16 std::tuple<int, int> loc_to_xy(int location) { 17 std::tuple<int, int> loc_to_xy(int location) {return _panel.loc_to_xy(location);}
17 return _panel.loc_to_xy(location); 18 int xy_to_loc(int x, int y) {return _panel.xy_to_loc(x, y);}
18 } 19 std::tuple<int, int> dloc_to_xy(int location) {return _panel.dloc_to_xy(location);}
19 20 int xy_to_dloc(int x, int y) {return _panel.xy_to_dloc(x, y);}
20 int xy_to_loc(int x, int y) {
21 return _panel.xy_to_loc(x, y);
22 }
23}; 21};
24 22
25TEST_F(PanelExtractionTests, LocToXY_7x5) { 23TEST_F(PanelExtractionTests, 1x1) {
24 SetPanelSize(1, 1);
25 /* Here's the panel, with the correct location order
26 0(_width = 1)
27 (_height = 1)
28 */
29 ASSERT_EQ(0, xy_to_loc(0, 0));
30 ASSERT_EQ((std::tuple<int, int>{0, 0}), loc_to_xy(0));
31}
32
33TEST_F(PanelExtractionTests, 7x1) {
34 SetPanelSize(7, 1);
35 /* Here's the panel, with the correct location order
36 3 . 2 . 1 . 0(_width = 7)
37 (_height = 1)
38 */
39 ASSERT_EQ(0, xy_to_loc(0, 0));
40 ASSERT_EQ(1, xy_to_loc(2, 0));
41 ASSERT_EQ(2, xy_to_loc(4, 0));
42 ASSERT_EQ(3, xy_to_loc(6, 0));
43 ASSERT_EQ((std::tuple<int, int>{0, 0}), loc_to_xy(0));
44 ASSERT_EQ((std::tuple<int, int>{2, 0}), loc_to_xy(1));
45 ASSERT_EQ((std::tuple<int, int>{4, 0}), loc_to_xy(2));
46 ASSERT_EQ((std::tuple<int, int>{6, 0}), loc_to_xy(3));
47}
48
49TEST_F(PanelExtractionTests, 1x7) {
50 SetPanelSize(1, 7);
51 /* Here's the panel, with the correct location order
52 3(_width = 1)
53 .
54 2
55 .
56 1
57 .
58 0
59 (_height = 7)
60 */
61 ASSERT_EQ(0, xy_to_loc(0, 6));
62 ASSERT_EQ(1, xy_to_loc(0, 4));
63 ASSERT_EQ(2, xy_to_loc(0, 2));
64 ASSERT_EQ(3, xy_to_loc(0, 0));
65 ASSERT_EQ((std::tuple<int, int>{0, 6}), loc_to_xy(0));
66 ASSERT_EQ((std::tuple<int, int>{0, 4}), loc_to_xy(1));
67 ASSERT_EQ((std::tuple<int, int>{0, 2}), loc_to_xy(2));
68 ASSERT_EQ((std::tuple<int, int>{0, 0}), loc_to_xy(3));
69}
70
71TEST_F(PanelExtractionTests, 3x3) {
72 SetPanelSize(3, 3);
73 /* Here's the panel, with the correct location order
74 2 . 3 (_width = 3)
75 . A .
76 0 . 1
77 (_height = 3)
78 */
79 ASSERT_EQ(0, xy_to_loc(0, 2));
80 ASSERT_EQ(1, xy_to_loc(2, 2));
81 ASSERT_EQ(2, xy_to_loc(0, 0));
82 ASSERT_EQ(3, xy_to_loc(2, 0));
83 ASSERT_EQ((std::tuple<int, int>{0, 2}), loc_to_xy(0));
84 ASSERT_EQ((std::tuple<int, int>{2, 2}), loc_to_xy(1));
85 ASSERT_EQ((std::tuple<int, int>{0, 0}), loc_to_xy(2));
86 ASSERT_EQ((std::tuple<int, int>{2, 0}), loc_to_xy(3));
87
88 ASSERT_EQ(0, xy_to_dloc(1, 1));
89 ASSERT_EQ((std::tuple<int, int>{1, 1}), dloc_to_xy(0));
90}
91
92TEST_F(PanelExtractionTests, 7x5) {
26 SetPanelSize(7, 5); 93 SetPanelSize(7, 5);
27 /* Here's the panel, with the correct location order 94 /* Here's the panel, with the correct location order
28 8 . 9 . 10. 11 (_width = 7) 95 8 . 9 . 10. 11 (_width = 7)
29 . . . . . . . 96 . D . E . F .
30 4 . 5 . 6 . 7 97 4 . 5 . 6 . 7
31 . . . . . . . 98 . A . B . C .
32 0 . 1 . 2 . 3 99 0 . 1 . 2 . 3
33 (_height = 5) 100 (_height = 5)
34 */ 101 */
@@ -36,28 +103,26 @@ TEST_F(PanelExtractionTests, LocToXY_7x5) {
36 ASSERT_EQ(1, xy_to_loc(2, 4)); 103 ASSERT_EQ(1, xy_to_loc(2, 4));
37 ASSERT_EQ(2, xy_to_loc(4, 4)); 104 ASSERT_EQ(2, xy_to_loc(4, 4));
38 ASSERT_EQ(3, xy_to_loc(6, 4)); 105 ASSERT_EQ(3, xy_to_loc(6, 4));
106 ASSERT_EQ((std::tuple<int, int>{0, 4}), loc_to_xy(0));
107 ASSERT_EQ((std::tuple<int, int>{2, 4}), loc_to_xy(1));
108 ASSERT_EQ((std::tuple<int, int>{4, 4}), loc_to_xy(2));
109 ASSERT_EQ((std::tuple<int, int>{6, 4}), loc_to_xy(3));
39 110
40 ASSERT_EQ(4, xy_to_loc(0, 2)); 111 ASSERT_EQ(4, xy_to_loc(0, 2));
41 ASSERT_EQ(5, xy_to_loc(2, 2)); 112 ASSERT_EQ(5, xy_to_loc(2, 2));
42 ASSERT_EQ(6, xy_to_loc(4, 2)); 113 ASSERT_EQ(6, xy_to_loc(4, 2));
43 ASSERT_EQ(7, xy_to_loc(6, 2)); 114 ASSERT_EQ(7, xy_to_loc(6, 2));
115 ASSERT_EQ((std::tuple<int, int>{0, 2}), loc_to_xy(4));
116 ASSERT_EQ((std::tuple<int, int>{2, 2}), loc_to_xy(5));
117 ASSERT_EQ((std::tuple<int, int>{4, 2}), loc_to_xy(6));
118 ASSERT_EQ((std::tuple<int, int>{6, 2}), loc_to_xy(7));
44 119
45 ASSERT_EQ(8, xy_to_loc(0, 0)); 120 ASSERT_EQ(8, xy_to_loc(0, 0));
46 ASSERT_EQ(9, xy_to_loc(2, 0)); 121 ASSERT_EQ(9, xy_to_loc(2, 0));
47 ASSERT_EQ(10, xy_to_loc(4, 0)); 122 ASSERT_EQ(10, xy_to_loc(4, 0));
48 ASSERT_EQ(11, xy_to_loc(6, 0)); 123 ASSERT_EQ(11, xy_to_loc(6, 0));
124 ASSERT_EQ((std::tuple<int, int>{0, 0}), loc_to_xy(8));
125 ASSERT_EQ((std::tuple<int, int>{2, 0}), loc_to_xy(9));
126 ASSERT_EQ((std::tuple<int, int>{4, 0}), loc_to_xy(10));
127 ASSERT_EQ((std::tuple<int, int>{6, 0}), loc_to_xy(11));
49} 128}
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