geometry_discrete_primitives_test.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 
3 #include "../../src/core/geometry_discrete_primitives.h"
4 
5 //============================================================================//
6 //=== DiscreteSegment2D ===//
7 //============================================================================//
8 
9 // 7x7 square, lines to each cell on edge, cw
10 
11 using DPoints = std::vector<DiscretePoint2D>;
12 
13 TEST(DiscreteSegment2DRasterizationTest, square00) {
14  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {0, 3}};
15  ASSERT_EQ(DPoints({{0, 0}, {0, 1}, {0, 2}, {0, 3}}), gen_pts);
16 }
17 
18 TEST(DiscreteSegment2DRasterizationTest, square02) {
19  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {1, 3}};
20  ASSERT_EQ(DPoints({{0, 0}, {0, 1}, {1, 2}, {1, 3}}), gen_pts);
21 }
22 
23 TEST(DiscreteSegment2DRasterizationTest, square04) {
24  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {2, 3}};
25  ASSERT_EQ(DPoints({{0, 0}, {1, 1}, {1, 2}, {2, 3}}), gen_pts);
26 }
27 
28 TEST(DiscreteSegment2DRasterizationTest, square07) {
29  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {3, 3}};
30  ASSERT_EQ(DPoints({{0, 0}, {1, 1}, {2, 2}, {3, 3}}), gen_pts);
31 }
32 
33 TEST(DiscreteSegment2DRasterizationTest, square10) {
34  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {3, 2}};
35  ASSERT_EQ(DPoints({{0, 0}, {1, 1}, {2, 1}, {3, 2}}), gen_pts);
36 }
37 
38 TEST(DiscreteSegment2DRasterizationTest, square12) {
39  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {3, 1}};
40  ASSERT_EQ(DPoints({{0, 0}, {1, 0}, {2, 1}, {3, 1}}), gen_pts);
41 }
42 
43 TEST(DiscreteSegment2DRasterizationTest, square15) {
44  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {3, 0}};
45  ASSERT_EQ(DPoints({{0, 0}, {1, 0}, {2, 0}, {3, 0}}), gen_pts);
46 }
47 
48 //
49 
50 TEST(DiscreteSegment2DRasterizationTest, square17) {
51  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {3, -1}};
52  ASSERT_EQ(DPoints({{0, 0}, {1, 0}, {2, -1}, {3, -1}}), gen_pts);
53 }
54 
55 TEST(DiscreteSegment2DRasterizationTest, square19) {
56  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {3, -2}};
57  ASSERT_EQ(DPoints({{0, 0}, {1, -1}, {2, -1}, {3, -2}}), gen_pts);
58 }
59 
60 TEST(DiscreteSegment2DRasterizationTest, square22) {
61  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {3, -3}};
62  ASSERT_EQ(DPoints({{0, 0}, {1, -1}, {2, -2}, {3, -3}}), gen_pts);
63 }
64 
65 TEST(DiscreteSegment2DRasterizationTest, square25) {
66  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {2, -3}};
67  ASSERT_EQ(DPoints({{0, 0}, {1, -1}, {1, -2}, {2, -3}}), gen_pts);
68 }
69 
70 TEST(DiscreteSegment2DRasterizationTest, square28) {
71  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {1, -3}};
72  ASSERT_EQ(DPoints({{0, 0}, {0, -1}, {1, -2}, {1, -3}}), gen_pts);
73 }
74 
75 TEST(DiscreteSegment2DRasterizationTest, square30) {
76  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {0, -3}};
77  ASSERT_EQ(DPoints({{0, 0}, {0, -1}, {0, -2}, {0, -3}}), gen_pts);
78 }
79 
80 TEST(DiscreteSegment2DRasterizationTest, square32) {
81  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-1, -3}};
82  ASSERT_EQ(DPoints({{0, 0}, {0, -1}, {-1, -2}, {-1, -3}}), gen_pts);
83 }
84 
85 TEST(DiscreteSegment2DRasterizationTest, square34) {
86  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-2, -3}};
87  ASSERT_EQ(DPoints({{0, 0}, {-1, -1}, {-1, -2}, {-2, -3}}), gen_pts);
88 }
89 
90 TEST(DiscreteSegment2DRasterizationTest, square37) {
91  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-3, -3}};
92  ASSERT_EQ(DPoints({{0, 0}, {-1, -1}, {-2, -2}, {-3, -3}}), gen_pts);
93 }
94 
95 TEST(DiscreteSegment2DRasterizationTest, square40) {
96  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-3, -2}};
97  ASSERT_EQ(DPoints({{0, 0}, {-1, -1}, {-2, -1}, {-3, -2}}), gen_pts);
98 }
99 
100 TEST(DiscreteSegment2DRasterizationTest, square42) {
101  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-3, -1}};
102  ASSERT_EQ(DPoints({{0, 0}, {-1, 0}, {-2, -1}, {-3, -1}}), gen_pts);
103 }
104 
105 //
106 TEST(DiscreteSegment2DRasterizationTest, square45) {
107  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-3, 0}};
108  ASSERT_EQ(DPoints({{0, 0}, {-1, 0}, {-2, 0}, {-3, 0}}), gen_pts);
109 }
110 
111 TEST(DiscreteSegment2DRasterizationTest, square48) {
112  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-3, 1}};
113  ASSERT_EQ(DPoints({{0, 0}, {-1, 0}, {-2, 1}, {-3, 1}}), gen_pts);
114 }
115 
116 TEST(DiscreteSegment2DRasterizationTest, square50) {
117  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-3, 2}};
118  ASSERT_EQ(DPoints({{0, 0}, {-1, 1}, {-2, 1}, {-3, 2}}), gen_pts);
119 }
120 
121 TEST(DiscreteSegment2DRasterizationTest, square53) {
122  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-3, 3}};
123  ASSERT_EQ(DPoints({{0, 0}, {-1, 1}, {-2, 2}, {-3, 3}}), gen_pts);
124 }
125 
126 TEST(DiscreteSegment2DRasterizationTest, square56) {
127  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-2, 3}};
128  ASSERT_EQ(DPoints({{0, 0}, {-1, 1}, {-1, 2}, {-2, 3}}), gen_pts);
129 }
130 
131 TEST(DiscreteSegment2DRasterizationTest, square58) {
132  DPoints gen_pts = DiscreteSegment2D{{0, 0}, {-1, 3}};
133  ASSERT_EQ(DPoints({{0, 0}, {0, 1}, {-1, 2}, {-1, 3}}), gen_pts);
134 }
135 
136 int main (int argc, char *argv[]) {
137  ::testing::InitGoogleTest(&argc, argv);
138  return RUN_ALL_TESTS();
139 }
std::vector< DiscretePoint2D > DPoints
int main(int argc, char *argv[])
TEST(DiscreteSegment2DRasterizationTest, square00)


slam_constructor
Author(s): JetBrains Research, OSLL team
autogenerated on Mon Jun 10 2019 15:08:25