Quantum Phenomena Explorer 7.9.8
Interactive quantum-phenomena Explorer Tutor — source documentation
Loading...
Searching...
No Matches
quantumbrightpass_tests.cpp
Go to the documentation of this file.
1/**
2 * @file quantumbrightpass_tests.cpp
3 * @brief Implements regression and invariant tests for quantumbrightpass tests.
4 * @ingroup qpe_tests
5 *
6 * Source: @c tests/quantumbrightpass_tests.cpp. This file is part of Quantum Phenomena Explorer (QPE),
7 * maintained by Officina Turini. See LICENSE_IT.txt / LICENSE.txt for the
8 * QPE freeware source-available terms and THIRD_PARTY_NOTICES.txt for
9 * third-party components.
10 */
11
13
15
16#include <cmath>
17
18namespace qpe {
19namespace tests {
20
21namespace {
22
23/**
24 * @brief Performs nearly equal.
25 * @param a The a value used by the operation.
26 * @param b The b value used by the operation.
27 * @param eps The eps value used by the operation.
28 */
29bool nearlyEqual(float a, float b, float eps = 1.0e-6f)
30{
31 return std::fabs(a - b) <= eps;
32}
33
34} // namespace
35
36/**
37 * @brief Runs quantum bright pass tests.
38 * @param error Output diagnostic text on failure.
39 */
40bool runQuantumBrightPassTests(std::string &error)
41{
42 error.clear();
43
44 if (!nearlyEqual(QuantumBrightPass::mask(0.49f, 0.50f, 0.0f), 0.0f)) {
45 error = "Hard threshold must reject luminance below threshold";
46 return false;
47 }
48 if (!nearlyEqual(QuantumBrightPass::mask(0.50f, 0.50f, 0.0f), 1.0f)) {
49 error = "Hard threshold must accept luminance at threshold";
50 return false;
51 }
52
53 if (!nearlyEqual(QuantumBrightPass::mask(0.50f, 0.50f, 0.10f), 0.5f)) {
54 error = "Soft knee must be half-selected at the threshold";
55 return false;
56 }
57
58 if (!nearlyEqual(QuantumBrightPass::mask(0.30f, 0.50f, 0.10f), 0.0f)) {
59 error = "Soft knee must fully reject luminance below its lower edge";
60 return false;
61 }
62 if (!nearlyEqual(QuantumBrightPass::mask(0.70f, 0.50f, 0.10f), 1.0f)) {
63 error = "Soft knee must fully select luminance above its upper edge";
64 return false;
65 }
66
67 return true;
68}
69
70} // namespace tests
71} // namespace qpe
static float mask(float luminance, float threshold, float softKnee)
Performs mask.
bool runQuantumBrightPassTests(std::string &error)
Runs quantum bright pass tests.
Declares the quantumbrightpass visualization component used by QPE.
Declares regression and invariant tests for quantumbrightpass tests.