| 285 | |
| 286 | template <class T> |
| 287 | void |
| 288 | testExtendByBox (const char* type) |
| 289 | { |
| 290 | cout << " extendBy() box for type " << type << endl; |
| 291 | |
| 292 | // |
| 293 | // Extend empty box with an empty box; |
| 294 | // |
| 295 | { |
| 296 | IMATH_INTERNAL_NAMESPACE::Box<T> b; |
| 297 | b.extendBy (IMATH_INTERNAL_NAMESPACE::Box<T> ()); |
| 298 | assert ( |
| 299 | b.min == T (T::baseTypeMax ()) && |
| 300 | b.max == T (T::baseTypeLowest ())); |
| 301 | } |
| 302 | |
| 303 | // |
| 304 | // Extend empty box with a non-empty box and vice versa. |
| 305 | // |
| 306 | { |
| 307 | std::vector<T> perms; |
| 308 | permutations (perms); |
| 309 | |
| 310 | for (unsigned int i = 0; i < perms.size (); i++) |
| 311 | { |
| 312 | for (unsigned int j = 0; j < perms.size (); j++) |
| 313 | { |
| 314 | T p0 = -perms[i]; |
| 315 | T p1 = perms[j]; |
| 316 | |
| 317 | IMATH_INTERNAL_NAMESPACE::Box<T> b0; |
| 318 | b0.extendBy (IMATH_INTERNAL_NAMESPACE::Box<T> (p0, p1)); |
| 319 | assert (b0.min == p0 && b0.max == p1); |
| 320 | |
| 321 | IMATH_INTERNAL_NAMESPACE::Box<T> b1 (p0, p1); |
| 322 | b1.extendBy (IMATH_INTERNAL_NAMESPACE::Box<T> ()); |
| 323 | assert (b1.min == p0 && b1.max == p1); |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | // |
| 329 | // Extend non-empty box with non-empty box. Starts with empty, then builds. |
| 330 | // |
| 331 | IMATH_INTERNAL_NAMESPACE::Rand32 rand (0); |
| 332 | const unsigned int iters = 10; |
| 333 | { |
| 334 | IMATH_INTERNAL_NAMESPACE::Box<T> b; |
| 335 | |
| 336 | T min, max; |
| 337 | |
| 338 | for (unsigned int i = 1; i < iters; i++) |
| 339 | { |
| 340 | T p0; |
| 341 | T p1; |
| 342 | for (unsigned int k = 0; k < T::dimensions (); k++) |
| 343 | { |
| 344 | p0[k] = typename T::BaseType (rand.nextf (0, 999)); |
nothing calls this directly
no test coverage detected