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

Function testColor

src/ImathTest/testColor.cpp:23–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21using namespace std;
22
23void
24testColor ()
25{
26 cout << "Testing functions in ImathColor.h & ImathColorAlgo.h" << endl;
27
28 cout << "rgb2packed -> packed2rgb" << endl;
29
30 const float epsilon = std::numeric_limits<float>::epsilon ();
31
32 IMATH_INTERNAL_NAMESPACE::PackedColor packed;
33 IMATH_INTERNAL_NAMESPACE::C3c in3 (52, 128, 254);
34 IMATH_INTERNAL_NAMESPACE::C3c out3;
35
36 packed = IMATH_INTERNAL_NAMESPACE::rgb2packed (in3);
37 IMATH_INTERNAL_NAMESPACE::packed2rgb (packed, out3);
38
39 assert (in3 == out3);
40
41 IMATH_INTERNAL_NAMESPACE::C4c testConstructor1;
42 IMATH_INTERNAL_NAMESPACE::C4c testConstructor1i (0);
43 IMATH_INTERNAL_NAMESPACE::C4c testConstructor2 (testConstructor1i);
44
45 testConstructor1 =
46 testConstructor2; // use these so the compiler doesn't emit a warning
47
48 IMATH_INTERNAL_NAMESPACE::C4c testConstructor3 (52, 128, 254, 127);
49 IMATH_INTERNAL_NAMESPACE::C4c A (testConstructor3);
50 IMATH_INTERNAL_NAMESPACE::C4c B;
51 IMATH_INTERNAL_NAMESPACE::C4f X, Y, tmp;
52
53 packed = IMATH_INTERNAL_NAMESPACE::rgb2packed (A);
54 IMATH_INTERNAL_NAMESPACE::packed2rgb (packed, B);
55
56 assert (A == B);
57
58 cout << "Imath::Color4 * f" << endl;
59
60 assert (
61 (IMATH_INTERNAL_NAMESPACE::C4f (0.330f, 0.710f, 0.010f, 0.999f) *
62 0.999f) ==
63 IMATH_INTERNAL_NAMESPACE::C4f (
64 0.330f * 0.999f,
65 0.710f * 0.999f,
66 0.010f * 0.999f,
67 0.999f * 0.999f));
68
69 cout << "Imath::Color4 / f" << endl;
70
71 assert (
72 (IMATH_INTERNAL_NAMESPACE::C4f (0.330f, 0.710f, 0.010f, 0.999f) /
73 0.999f) ==
74 IMATH_INTERNAL_NAMESPACE::C4f (
75 0.330f / 0.999f,
76 0.710f / 0.999f,
77 0.010f / 0.999f,
78 0.999f / 0.999f));
79
80 cout << "Assignment and comparison" << endl;

Callers

nothing calls this directly

Calls 4

fabsFunction · 0.85
rgb2hsvFunction · 0.50
hsv2rgbFunction · 0.50
equalFunction · 0.50

Tested by

no test coverage detected