| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/tests/src/test_commonutils.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include <catch2/catch_all.hpp> |
| 5 | |
| 6 | #include "core/components/commonutils.h"cxx . . $ `<file>/src/core/components/commonutils.h`/ |
| 7 | #include <units.h> |
| 8 | |
| 9 | namespace Testscxx . . $ Tests/::Utilscxx . . $ Tests/Utils/::Commoncxx . . $ Tests/Utils/Common/ { |
| 10 | |
| 11 | TEST_CASEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:144:11`!("CommonUtils tests", "[Utils][Common]") |
| 12 | { |
| 13 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("normalizePoints...") |
| 14 | { |
| 15 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("clamp points into range") |
| 16 | { |
| 17 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#, unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#>> |
| 18 | pointscxx . . $ std/vector#vector(9619226211e5a241).{stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(0), |
| 19 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(100)), |
| 20 | stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(50), |
| 21 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(150)), |
| 22 | stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(90), |
| 23 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(200))}; |
| 24 | |
| 25 | auto tempRange = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(0), |
| 26 | unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(50)); |
| 27 | |
| 28 | ::Utilscxx . . $ Utils/::Commoncxx . . $ Utils/Common/::normalizePointscxx . . $ Utils/Common/normalizePoints(c5e3ead2f69f5981).(points, tempRangecxx . . $ std/pair#pair(31533a781ed7dba3).); |
| 29 | |
| 30 | // temperature range |
| 31 | REQUIRE_FALSEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:128:11`!( |
| 32 | std::any_of(points.cbegin(), points.cend(), [&](auto const &point) { |
| 33 | return point.first < tempRange.first || |
| 34 | point.first > tempRange.second; |
| 35 | })); |
| 36 | |
| 37 | // percentage range |
| 38 | REQUIRE_FALSEcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:128:11`!( |
| 39 | std::any_of(points.cbegin(), points.cend(), [&](auto const &point) { |
| 40 | return point.second < units::concentration::percent_t(0) || |
| 41 | point.second > units::concentration::percent_t(100); |
| 42 | })); |
| 43 | } |
| 44 | |
| 45 | SECTIONcxx . . $ `<external>/1821973855936310166/catch_test_macros.hpp:149:11`!("clamp inner points y-axis coordinates into [prev.y, next.y] range") |
| 46 | { |
| 47 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#, unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#>> |
| 48 | pointscxx . . $ std/vector#vector(9619226211e5a241).{stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(0), |
| 49 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(20)), |
| 50 | stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(30), |
| 51 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(10)), |
| 52 | stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(60), |
| 53 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(30)), |
| 54 | stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(100), |
| 55 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(25))}; |
| 56 | |
| 57 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#, unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#>> |
| 58 | normalizedPointscxx . . $ std/vector#vector(9619226211e5a241).{stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(0), |
| 59 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(20)), |
| 60 | stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(30), |
| 61 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(20)), |
| 62 | stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(60), |
| 63 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(30)), |
| 64 | stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(100), |
| 65 | unitscxx . . $ units/::concentrationcxx . . $ units/concentration/::percent_tcxx . . $ units/concentration/percent_t#(30))}; |
| 66 | |
| 67 | auto tempRange = stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(0), |
| 68 | unitscxx . . $ units/::temperaturecxx . . $ units/temperature/::celsius_tcxx . . $ units/temperature/celsius_t#(100)); |
| 69 | |
| 70 | ::Utilscxx . . $ Utils/::Commoncxx . . $ Utils/Common/::normalizePointscxx . . $ Utils/Common/normalizePoints(c5e3ead2f69f5981).(points, tempRangecxx . . $ std/pair#pair(31533a781ed7dba3).); |
| 71 | |
| 72 | REQUIRE_THATcxx . . $ `<external>/3333208929440565380/catch_matchers.hpp:222:11`!(points, Catch::Matchers::Equals(normalizedPoints)); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | } // namespace Tests::Utils::Common |