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

Function testIsEmpty

src/ImathTest/testBox.cpp:726–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

724
725template <class T>
726void
727testIsEmpty (const char* type)
728{
729 cout << " isEmpty() for type " << type << endl;
730
731 //
732 // Empty box.
733 //
734 {
735 IMATH_INTERNAL_NAMESPACE::Box<T> b;
736 assert (b.isEmpty ());
737 }
738
739 //
740 // Non-empty, has-volume box.
741 // 2D: [(-2, -4), ( 8, 2) ]
742 // 3D: [(-2, -4, -6), (12, 8, 2) ]
743 // 4D: [(-2, -4, -6, -8), (16, 12, 8, 4) ]
744 //
745 {
746 IMATH_INTERNAL_NAMESPACE::Box<T> b0 (T (-1), T (1));
747 assert (!b0.isEmpty ());
748
749 T p0;
750 T p1;
751 for (unsigned int i = 0; i < T::dimensions (); i++)
752 {
753 int lo = 1 << (i + 1);
754 int hi = 1 << (T::dimensions () - i);
755 p0[i] = -static_cast<typename T::BaseType>(lo);
756 p1[i] = static_cast<typename T::BaseType>(hi);
757 }
758 IMATH_INTERNAL_NAMESPACE::Box<T> b1 (p0, p1);
759 assert (!b1.isEmpty ());
760 }
761
762 //
763 // Non-empty, no-volume box.
764 // Boxes are:
765 // 2D: [(0, 0), (0, 2) ]
766 // 3D: [(0, 0, 0), (0, 0, 2) ]
767 // 4D: [(0, 0, 0, 0), (0, 0, 0, 2)]
768 //
769 {
770 T min (0);
771 T max = min;
772 max[T::dimensions () - 1] = 2;
773
774 IMATH_INTERNAL_NAMESPACE::Box<T> b (min, max);
775
776 assert (!b.isEmpty ());
777 }
778}
779
780template <class T>
781void

Callers

nothing calls this directly

Calls 2

TClass · 0.50
dimensionsFunction · 0.50

Tested by

no test coverage detected