diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2018-11-07 10:09:47 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2018-11-07 10:09:47 -0800 |
commit | c388759ed67b792201b99bf7d73d036c34b47d87 (patch) | |
tree | d16e7bdba8e1f226bd97b9a774fcb519c2bebd42 /Test | |
parent | 5ad08f6611c8c777c43cfa0d2380b6ad6554a54d (diff) | |
download | witness-tutorializer-c388759ed67b792201b99bf7d73d036c34b47d87.tar.gz witness-tutorializer-c388759ed67b792201b99bf7d73d036c34b47d87.tar.bz2 witness-tutorializer-c388759ed67b792201b99bf7d73d036c34b47d87.zip |
Working on some consistency
Diffstat (limited to 'Test')
-rw-r--r-- | Test/PanelExtractionTests.cpp | 63 | ||||
-rw-r--r-- | Test/Test.vcxproj | 1 |
2 files changed, 64 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 | |||
4 | class PanelExtractionTests : public testing::Test | ||
5 | { | ||
6 | protected: | ||
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 | |||
25 | TEST_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 | |||
51 | TEST_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 | ||
diff --git a/Test/Test.vcxproj b/Test/Test.vcxproj index a6d8f75..55f3ce8 100644 --- a/Test/Test.vcxproj +++ b/Test/Test.vcxproj | |||
@@ -33,6 +33,7 @@ | |||
33 | <ImportGroup Label="PropertySheets" /> | 33 | <ImportGroup Label="PropertySheets" /> |
34 | <PropertyGroup Label="UserMacros" /> | 34 | <PropertyGroup Label="UserMacros" /> |
35 | <ItemGroup> | 35 | <ItemGroup> |
36 | <ClCompile Include="PanelExtractionTests.cpp" /> | ||
36 | <ClCompile Include="Temp.cpp" /> | 37 | <ClCompile Include="Temp.cpp" /> |
37 | <ClCompile Include="RandomTests.cpp" /> | 38 | <ClCompile Include="RandomTests.cpp" /> |
38 | </ItemGroup> | 39 | </ItemGroup> |