test_blockmem_gridmap.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, the neonavigation authors
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include <cstddef>
31 #include <limits>
32 
33 #include <gtest/gtest.h>
34 
36 
37 TEST(BlockmemGridmap, ResetClear)
38 {
40 
41  for (int s = 4; s <= 6; s += 2)
42  {
43  gm.reset(CyclicVecInt<3, 3>(s, s, s));
44  gm.clear(0.0);
45 
47  for (i[0] = 0; i[0] < s; ++i[0])
48  {
49  for (i[1] = 0; i[1] < s; ++i[1])
50  {
51  for (i[2] = 0; i[2] < s; ++i[2])
52  {
53  ASSERT_EQ(gm[i], 0.0);
54  }
55  }
56  }
57 
58  gm.clear(3.0);
59  for (i[0] = 0; i[0] < s; ++i[0])
60  {
61  for (i[1] = 0; i[1] < s; ++i[1])
62  {
63  for (i[2] = 0; i[2] < s; ++i[2])
64  {
65  ASSERT_EQ(gm[i], 3.0);
66  }
67  }
68  }
69  }
70 }
71 
72 TEST(BlockmemGridmap, WriteRead)
73 {
75 
76  const int s = 4;
77  gm.reset(CyclicVecInt<3, 3>(s, s, s));
78  gm.clear(0.0);
79 
81  for (i[0] = 0; i[0] < s; ++i[0])
82  {
83  for (i[1] = 0; i[1] < s; ++i[1])
84  {
85  for (i[2] = 0; i[2] < s; ++i[2])
86  {
87  gm[i] = i[2] * 100 + i[1] * 10 + i[0];
88  }
89  }
90  }
91 
92  for (i[0] = 0; i[0] < s; ++i[0])
93  {
94  for (i[1] = 0; i[1] < s; ++i[1])
95  {
96  for (i[2] = 0; i[2] < s; ++i[2])
97  {
98  ASSERT_EQ(gm[i], i[2] * 100 + i[1] * 10 + i[0]);
99  }
100  }
101  }
102 }
103 
104 TEST(BlockmemGridmap, OuterBoundery)
105 {
107 
108  const int s = 0x30;
109  gm.reset(CyclicVecInt<3, 2>(s, s, s));
110  gm.clear(1.0);
111 
113  const int outer = 0x10;
114  for (i[0] = -outer; i[0] < s + outer; ++i[0])
115  {
116  for (i[1] = -outer; i[1] < s + outer; ++i[1])
117  {
118  for (i[2] = -outer; i[2] < s + outer; ++i[2])
119  {
120  if (i[0] >= 0 && i[1] >= 0 && i[2] >= 0 &&
121  i[0] < s && i[1] < s && i[2] < s)
122  {
123  ASSERT_TRUE(gm.validate(i));
124  }
125  else
126  {
127  ASSERT_FALSE(gm.validate(i));
128  }
129  // Confirm at least not dead
130  gm[i] = 1.0;
131  }
132  }
133  }
134 }
135 
136 int main(int argc, char** argv)
137 {
138  testing::InitGoogleTest(&argc, argv);
139 
140  return RUN_ALL_TESTS();
141 }
XmlRpcServer s
void reset(const CyclicVecInt< DIM, NONCYCLIC > &size)
TEST(BlockmemGridmap, ResetClear)
bool validate(const CyclicVecInt< DIM, NONCYCLIC > &pos, const int tolerance=0) const
void clear(const T zero)
int main(int argc, char **argv)


planner_cspace
Author(s): Atsushi Watanabe
autogenerated on Tue Jul 9 2019 05:00:13