2 Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file test/colour_conversion_test.cc
21 * @brief Various tests of ColourConversion.
24 #include "lib/colour_conversion.h"
25 #include <dcp/colour_matrix.h>
26 #include <dcp/gamma_transfer_function.h>
27 #include <libxml++/libxml++.h>
28 #include <boost/test/unit_test.hpp>
31 using boost::shared_ptr;
33 BOOST_AUTO_TEST_CASE (colour_conversion_test1)
35 ColourConversion A (dcp::ColourConversion::srgb_to_xyz ());
36 ColourConversion B (dcp::ColourConversion::rec709_to_xyz ());
38 BOOST_CHECK_EQUAL (A.identifier(), "751dd37378fb52502d356ec334a104c8");
39 BOOST_CHECK_EQUAL (B.identifier(), "149bc864d969ad7446fa18d62d1690b2");
42 BOOST_AUTO_TEST_CASE (colour_conversion_test2)
44 ColourConversion A (dcp::ColourConversion::srgb_to_xyz ());
46 xmlpp::Element* root = doc.create_root_node ("Test");
49 doc.write_to_string_formatted ("UTF-8"),
50 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
52 " <InputTransferFunction>\n"
53 " <Type>ModifiedGamma</Type>\n"
54 " <Power>2.4</Power>\n"
55 " <Threshold>0.04045</Threshold>\n"
58 " </InputTransferFunction>\n"
59 " <Matrix i=\"0\" j=\"0\">0.4124564</Matrix>\n"
60 " <Matrix i=\"0\" j=\"1\">0.3575761</Matrix>\n"
61 " <Matrix i=\"0\" j=\"2\">0.1804375</Matrix>\n"
62 " <Matrix i=\"1\" j=\"0\">0.2126729</Matrix>\n"
63 " <Matrix i=\"1\" j=\"1\">0.7151522</Matrix>\n"
64 " <Matrix i=\"1\" j=\"2\">0.072175</Matrix>\n"
65 " <Matrix i=\"2\" j=\"0\">0.0193339</Matrix>\n"
66 " <Matrix i=\"2\" j=\"1\">0.119192</Matrix>\n"
67 " <Matrix i=\"2\" j=\"2\">0.9503041</Matrix>\n"
68 " <OutputGamma>2.6</OutputGamma>\n"
73 BOOST_AUTO_TEST_CASE (colour_conversion_test3)
75 ColourConversion A (dcp::ColourConversion::rec709_to_xyz ());
77 xmlpp::Element* root = doc.create_root_node ("Test");
80 doc.write_to_string_formatted ("UTF-8"),
81 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
83 " <InputTransferFunction>\n"
84 " <Type>ModifiedGamma</Type>\n"
85 " <Power>2.4</Power>\n"
86 " <Threshold>0.081</Threshold>\n"
89 " </InputTransferFunction>\n"
90 " <Matrix i=\"0\" j=\"0\">0.4124564</Matrix>\n"
91 " <Matrix i=\"0\" j=\"1\">0.3575761</Matrix>\n"
92 " <Matrix i=\"0\" j=\"2\">0.1804375</Matrix>\n"
93 " <Matrix i=\"1\" j=\"0\">0.2126729</Matrix>\n"
94 " <Matrix i=\"1\" j=\"1\">0.7151522</Matrix>\n"
95 " <Matrix i=\"1\" j=\"2\">0.072175</Matrix>\n"
96 " <Matrix i=\"2\" j=\"0\">0.0193339</Matrix>\n"
97 " <Matrix i=\"2\" j=\"1\">0.119192</Matrix>\n"
98 " <Matrix i=\"2\" j=\"2\">0.9503041</Matrix>\n"
99 " <OutputGamma>2.6</OutputGamma>\n"