File: HashGrid3_test.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 239,848 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 93
file content (267 lines) | stat: -rw-r--r-- 6,087 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/CONCEPT/classTest.h>

///////////////////////////

#include <BALL/DATATYPE/hashGrid.h>
#include <BALL/SYSTEM/sysinfo.h>
#include "HashGrid3_test.h"

///////////////////////////

START_TEST(HashGrid3)

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

using namespace BALL;

// tests for class HashGrid3::

HashGrid3<int>* hg_ptr;

CHECK(HashGrid3() throw())
	hg_ptr = new HashGrid3<int>;
	TEST_NOT_EQUAL(hg_ptr, 0)
RESULT


CHECK(~HashGrid3() throw())
	delete hg_ptr;
RESULT


CHECK(HashGrid3(const Vector3& origin, Size dimension_x, Size dimension_y, Size dimension_z, float spacing_x, float spacing_y, float spacing_z) throw())
	Vector3 origin(1.0, 2.0, 3.0);
	Size dimension_x = 1;
	Size dimension_y = 4;
	Size dimension_z = 7;
	float spacing_x = 1.23;
	float spacing_y = 4.56;
	float spacing_z = 7.89;
	HashGrid3<int> hg(origin, dimension_x, dimension_y, dimension_z,
			spacing_x, spacing_y, spacing_z);
	TEST_EQUAL(hg.getOrigin(), origin)
	TEST_EQUAL(hg.getSizeX(), dimension_x)
	TEST_EQUAL(hg.getSizeY(), dimension_y)
	TEST_EQUAL(hg.getSizeZ(), dimension_z)
RESULT


CHECK(HashGrid3(const Vector3& origin, Size dimension_x, Size dimension_y, Size dimension_z, float spacing) throw())
	Vector3 origin(1.0, 2.0, 3.0);
	Size dimension_x = 1;
	Size dimension_y = 4;
	Size dimension_z = 7;
	float spacing = 3.14;
	HashGrid3<int> hg(origin, dimension_x, dimension_y, dimension_z, spacing);
	TEST_EQUAL(hg.getOrigin(), origin)
	TEST_EQUAL(hg.getSizeX(), dimension_x)
	TEST_EQUAL(hg.getSizeY(), dimension_y)
	TEST_EQUAL(hg.getSizeZ(), dimension_z)
RESULT


CHECK(HashGrid3(const Vector3& origin, const Vector3& size, float spacing) throw())
	Vector3 origin(1.0, 2.0, 3.0);
	Vector3 size(4.0, 5.0, 6.0);
	float spacing = 3.14;
	HashGrid3<int> hg(origin, size, spacing);
	TEST_EQUAL(hg.getOrigin(), origin)
	TEST_EQUAL(hg.getSizeX(), 2)
	TEST_EQUAL(hg.getSizeY(), 2)
	TEST_EQUAL(hg.getSizeZ(), 2)
RESULT


CHECK(BALL_CREATE(HashGrid3))
  // ???
RESULT

CHECK(void clear(Position x, Position y, Position z) throw())
  // ???
RESULT

CHECK(void clear(const Vector3 &vector) throw())
  // ???
RESULT

CHECK(void destroy() throw())
  // ???
RESULT

CHECK(void destroy(Position x, Position y, Position z) throw())
  // ???
RESULT

CHECK(void destroy(const Vector3& vector) throw())
  // ???
RESULT

CHECK(void dump(std::ostream& s = std::cout, Size depth = 0) const throw())
  // ???
RESULT

CHECK(void get(HashGrid3& grid, bool deep = true) const throw())
  // ???
RESULT

CHECK(void get(Vector3& origin, Vector3& unit, Size& dimension_x, Size& dimension_y, Size& dimension_z) const throw())
  // ???
RESULT

CHECK(void host(Visitor<HashGrid3>& visitor) throw())
  // ???
RESULT

CHECK(void insert(Position x, Position y, Position z, const Item& item) throw())
  // ???
RESULT

CHECK(void insert(const Vector3& vector, const Item& item) throw())
  // ???
RESULT

CHECK(void set(const HashGrid3& grid, bool deep = true) throw())
  // ???
RESULT

CHECK(void set(const Vector3& origin, const Vector3& unit, Size dimension_x, Size dimension_y, Size dimension_z) throw())
  // ???
RESULT

CHECK(bool getIndices(const HashGridBox3<Item>& box, Position& x, Position& y, Position& z) const throw())
  // ???
RESULT

CHECK(bool isEmpty() const throw())
  // ???
RESULT

CHECK(bool isValid() const throw())
  // ???
RESULT

CHECK(bool operator != (const HashGrid3& grid) const throw())
  // ???
RESULT

CHECK(bool operator == (const HashGrid3& grid) const throw())
  // ???
RESULT

CHECK(bool remove(Position x, Position y, Position z, const Item& item) throw())
  // ???
RESULT

CHECK(bool remove(const Vector3& vector, const Item& item) throw())
  // ???
RESULT

CHECK(const HashGrid3& operator = (const HashGrid3& grid) throw())
  // ???
RESULT

CHECK(const HashGridBox3<Item>* getBox(Position x, Position y, Position z) const throw())
  // ???
RESULT

CHECK(const HashGridBox3<Item>* getBox(const Vector3 &vector) const throw())
  // ???
RESULT

CHECK(const Vector3& getOrigin() const throw())
  // ???
RESULT

CHECK(const Vector3& getUnit() const throw())
  // ???
RESULT

CHECK(void clear() throw())
  // ???
RESULT

CHECK(void set(const Vector3& origin, float unit, Size size) throw())
  // ???
RESULT

CHECK(HashGrid3(const HashGrid3& grid, bool deep = true) throw())
  // ???
RESULT

CHECK(HashGridBox3<Item>* getBox(Position x, Position y, Position z) throw())
  // ???
RESULT

CHECK(HashGridBox3<Item>* getBox(const Vector3& vector) throw())
  // ???
RESULT

CHECK(Size countNonEmptyBoxes() const)
	HashGrid3<char> testGrid(Vector3(), 20, 30, 40, 1, 1, 1);

	TEST_EQUAL(0, testGrid.countNonEmptyBoxes());

	testGrid.insert(1.f, 2.f, 3.f, 'a');
	TEST_EQUAL(1, testGrid.countNonEmptyBoxes());
	testGrid.insert(1.f, 2.f, 3.f, 'b');
	TEST_EQUAL(1, testGrid.countNonEmptyBoxes());

	testGrid.insert(.2f, 2.f, 1.f, 'c');
	TEST_EQUAL(2, testGrid.countNonEmptyBoxes());

	for(HashGrid3<char>::BoxIterator it = testGrid.beginBox(); +it; ++it) {
		it->insert('a');
	}
	TEST_EQUAL(20 * 30 * 40, testGrid.countNonEmptyBoxes());
RESULT

CHECK(Size getSize() const throw())
  // ???
RESULT

CHECK(Size getSizeX() const throw())
  // ???
RESULT

CHECK(Size getSizeY() const throw())
  // ???
RESULT

CHECK(Size getSizeZ() const throw())
  // ???
RESULT

CHECK(Vector3& getOrigin() throw())
  // ???
RESULT

CHECK(Vector3& getUnit() throw())
  // ???
RESULT

CHECK(bool apply(UnaryProcessor< HashGridBox3<Item> > &processor) throw())
  // ???
RESULT

CHECK(bool apply(UnaryProcessor<Item> &processor) throw())
  // ???
RESULT

CHECK(calculateMinSpacing)
	LongIndex memory = 10000000;
	Vector3 size = Vector3(1000., 1000., 1000.);

	float spacing = HashGrid3<float>::calculateMinSpacing(memory, size);
 	STATUS("spacing: " << spacing)	
	HashGrid3<float> hg(Vector3(0.0), size, spacing);
	TEST_EQUAL((spacing < 35.), true)
RESULT

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST