test-table-parsing.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 
9 
11 
12 
13 TEST_CASE("parse_thermal_table", "[thermal-loop]")
14 {
15  auto original_table = create_synthetic_table();
16  auto raw_data = original_table.build_raw_data();
17  thermal_calibration_table table_from_raw( raw_data );
18  REQUIRE( original_table == table_from_raw );
19 }
20 
21 TEST_CASE( "invalid thermal table", "[thermal-loop]" )
22 {
24  table._header.valid = 0.f;
25 
26  auto raw_data = table.build_raw_data();
28 }
29 
30 TEST_CASE( "data_size_too_small", "[thermal-loop]" )
31 {
32  auto syntetic_table = create_synthetic_table();
33  auto raw_data = syntetic_table.build_raw_data();
34  raw_data.pop_back();
36 }
37 
38 TEST_CASE( "data_size_too_large", "[thermal-loop]" )
39 {
40  auto syntetic_table = create_synthetic_table();
41  auto raw_data = syntetic_table.build_raw_data();
42  raw_data.push_back( 1 );
44 }
45 
46 TEST_CASE( "build_raw_data", "[thermal-loop]" )
47 {
48  auto syntetic_table = create_synthetic_table(1);
49  auto raw_data = syntetic_table.build_raw_data();
50 
51  std::vector< byte > raw;
52 
53  raw.insert( raw.end(),
54  (byte *)&( syntetic_table._header.min_temp ),
55  (byte *)&( syntetic_table._header.min_temp ) + 4 );
56 
57  raw.insert( raw.end(),
58  (byte *)&( syntetic_table._header.max_temp ),
59  (byte *)&( syntetic_table._header.max_temp ) + 4 );
60 
61  raw.insert( raw.end(),
62  (byte *)&( syntetic_table._header.reference_temp ),
63  (byte *)&( syntetic_table._header.reference_temp ) + 4 );
64 
65  raw.insert( raw.end(),
66  (byte *)&( syntetic_table._header.valid ),
67  (byte *)&( syntetic_table._header.valid ) + 4 );
68 
69  for (auto v : syntetic_table.bins)
70  {
71  raw.insert( raw.end(),
72  (byte *)&( v.scale ),
73  (byte *)&( v.scale ) + 4 );
74 
75  raw.insert( raw.end(), (byte *)&( v.sheer ), (byte *)&( v.sheer ) + 4 );
76  raw.insert( raw.end(), (byte *)&( v.tx ), (byte *)&( v.tx ) + 4 );
77  raw.insert( raw.end(), (byte *)&( v.ty ), (byte *)&( v.ty ) + 4 );
78  }
79 
80  CHECK( raw_data == raw );
81  REQUIRE_THROWS( thermal_calibration_table( raw_data, 2 ) );
82 }
83 
84 TEST_CASE( "build_raw_data_no_data", "[thermal-loop]" )
85 {
86  auto syntetic_table = create_synthetic_table( 0 );
87  auto raw_data = syntetic_table.build_raw_data();
88 
89  thermal_calibration_table t( raw_data, 0 );
90 
91  CHECK( t.bins.size() == 0 );
92 }
TEST_CASE("parse_thermal_table","[thermal-loop]")
thermal::thermal_calibration_table create_synthetic_table(const int table_size=29, float min_temp=0, float max_temp=75)
GLdouble t
REQUIRE(n_callbacks==1)
#define REQUIRE_THROWS(...)
Definition: catch.hpp:17401
GLenum GLenum GLsizei void * table
unsigned char byte
Definition: src/types.h:52
GLdouble v
#define CHECK(condition)


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