test-get-scale.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 //#cmake:add-file ../../../src/algo/thermal-loop/*.cpp
5 #include "../algo-common.h"
8 
10 
11 
12 
13 TEST_CASE("get_scale", "[thermal-loop]")
14 {
15  auto syntetic_table = create_synthetic_table();
16  // [0 - 2.5] --> 0.5
17  // (2.5 - 5] --> 1
18  // (5 - 7.5] --> 1.5
19  // (7.5 - 10] --> 2
20  // ...
21  // (72.5 - 75] --> 15
22 
23  std::map< double, double > temp_to_expected_scale = {
24  { -1, 0.5 }, // under minimum temp
25  { 0, 0.5 },
26  { 2.5, 0.5 },
27  { 3.56756, 1 },
28  { 5, 1 },
29  { 7.5, 1.5 },
30  { 7.6, 2 },
31  { 73, 14.5 },
32  { 75, 14.5 }, // maximum temp
33  { 78, 14.5 }, // above maximum temp
34  };
35 
36  for (auto temp_scale : temp_to_expected_scale)
37  {
38  TRACE( "checking temp = " << temp_scale.first );
39  REQUIRE( syntetic_table.get_thermal_scale( temp_scale.first )
40  == 1. / temp_scale.second );
41  }
42 }
43 
44 TEST_CASE( "scale_is_zero", "[thermal-loop]" )
45 {
46  auto syntetic_table = create_synthetic_table();
47  syntetic_table.bins[0].scale = 0;
48  REQUIRE_THROWS( syntetic_table.get_thermal_scale( 0 ) );
49 }
thermal::thermal_calibration_table create_synthetic_table(const int table_size=29, float min_temp=0, float max_temp=75)
REQUIRE(n_callbacks==1)
#define REQUIRE_THROWS(...)
Definition: catch.hpp:17401
TEST_CASE("get_scale","[thermal-loop]")


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11