Fix silent stereo mixdown exports when the project audio channel count is > 6.
[dcpomatic.git] / test / kdm_util_test.cc
1 /*
2     Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "lib/kdm_util.h"
23 #include <dcp/certificate.h>
24 #include <dcp/util.h>
25 #include <boost/test/unit_test.hpp>
26
27
28 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_good)
29 {
30         auto const result = check_kdm_and_certificate_validity_periods(
31                 "Bob's Place",
32                 "Country",
33                 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
34                 dcp::LocalTime("2023-01-03T10:30:00"),
35                 dcp::LocalTime("2050-10-20T14:00:00")
36                 );
37
38         BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_WITHIN_CERTIFICATE);
39 }
40
41
42 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_overlap_start)
43 {
44         auto const result = check_kdm_and_certificate_validity_periods(
45                 "Bob's Place",
46                 "Western",
47                 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
48                 dcp::LocalTime("2011-01-03T10:30:00"),
49                 dcp::LocalTime("2050-10-20T14:00:00")
50                 );
51
52         BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE);
53 }
54
55
56 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_overlap_end)
57 {
58         auto const result = check_kdm_and_certificate_validity_periods(
59                 "Palace Hotel Ballroom",
60                 "Lobby",
61                 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
62                 dcp::LocalTime("2033-01-03T10:30:00"),
63                 dcp::LocalTime("2095-10-20T14:00:00")
64                 );
65
66         BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE);
67 }
68
69
70 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_overlap_start_and_end)
71 {
72         auto const result = check_kdm_and_certificate_validity_periods(
73                 "Palace Hotel Ballroom",
74                 "Stage",
75                 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
76                 dcp::LocalTime("2011-01-03T10:30:00"),
77                 dcp::LocalTime("2095-10-20T14:00:00")
78                 );
79
80         BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE);
81 }
82
83
84 BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_outside)
85 {
86         auto const result = check_kdm_and_certificate_validity_periods(
87                 "Palace Hotel Ballroom",
88                 "Drum Riser",
89                 dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
90                 dcp::LocalTime("2011-01-03T10:30:00"),
91                 dcp::LocalTime("2012-10-20T14:00:00")
92                 );
93
94         BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_OUTSIDE_CERTIFICATE);
95 }