+
+/** Convert a test image from sRGB to XYZ and check that the transforms are right */
+BOOST_AUTO_TEST_CASE (rgb_xyz_test)
+{
+ {
+ int counter = 0;
+ rgb_xyz_test_case ([&counter](uint16_t* p) {
+ p[0] = p[1] = p[2] = (counter << 4);
+ ++counter;
+ if (counter >= 4096) {
+ counter = 0;
+ }
+ });
+ }
+
+ boost::random::mt19937 rng(1);
+ boost::random::uniform_int_distribution<> dist(0, 4095);
+
+ rgb_xyz_test_case ([&rng, &dist](uint16_t* p) {
+ p[0] = dist(rng) << 4;
+ p[1] = dist(rng) << 4;
+ p[2] = dist(rng) << 4;
+ });
+}
+
+
+/** Check the piecewise LUT that is used for inverse gamma calculation */
+BOOST_AUTO_TEST_CASE (rgb_xyz_lut_test)
+{
+ auto conversion = dcp::ColourConversion::rec709_to_xyz();
+ auto lut = dcp::make_inverse_gamma_lut(conversion.out());
+
+ for (double x = 0; x < 1; x += 0.000001) {
+ BOOST_CHECK(std::abs(lrint(lut.lookup(x) * 4095) - lrint(pow(x, 1 / 2.6) * 4095)) < 2);
+ }
+}
+
+