MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / testExtendByPoint

Function testExtendByPoint

src/ImathTest/testInterval.cpp:157–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156template <class T>
157void
158testExtendByPoint (const char* type)
159{
160 cout << " extendBy() point for type " << type << endl;
161
162 IMATH_INTERNAL_NAMESPACE::Rand32 rand (0);
163
164 const unsigned int iters = 10;
165
166 //
167 // Extend empty interval with a single point.
168 //
169 for (unsigned int i = 0; i < iters; i++)
170 {
171 T p (static_cast<T>(rand.nextf (-12345, 12345)));
172 IMATH_INTERNAL_NAMESPACE::Interval<T> b;
173 b.extendBy (p);
174 assert (b.min == p && b.max == p);
175 }
176
177 //
178 // Extend empty interval with a number of random points. Note that
179 // this also covers extending a non-empty interval.
180 //
181 for (unsigned int i = 0; i < iters; i++)
182 {
183 IMATH_INTERNAL_NAMESPACE::Interval<T> b;
184
185 T min;
186 T max;
187
188 for (unsigned int j = 0; j < i; j++)
189 {
190 T p (static_cast<T>(rand.nextf (-12345, 12345)));
191
192 if (j == 0)
193 {
194 min = p;
195 max = p;
196 }
197
198 min = std::min (min, p);
199 max = std::max (max, p);
200
201 b.extendBy (p);
202
203 assert (b.min == min && b.max == max);
204 }
205 }
206}
207
208template <class T>
209void

Callers

nothing calls this directly

Calls 2

extendByMethod · 0.80
nextfMethod · 0.60

Tested by

no test coverage detected