byte_array.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <gtest/gtest.h>
14 #include "../../include/ecl/converters_lite/byte_array.hpp"
15 
16 /*****************************************************************************
17 ** Globals
18 *****************************************************************************/
19 
20 bool debug_output = true;
21 
22 /*****************************************************************************
23 ** Tests
24 *****************************************************************************/
25 
26 TEST(ConverterTests,byteArrays) {
27  ecl::int32 value;
28  ecl::uint32 u_value;
29  char three_six_three[4] = { 0x6b, 0x01, 0x00, 0x00 };
30  unsigned char u_three_six_three[4] = { 0x6b, 0x01, 0x00, 0x00 };
31  char minus_two[4] = { 0xfe, 0xff, 0xff, 0xff };
32  unsigned char u_minus_two[4] = { 0xfe, 0xff, 0xff, 0xff };
33  ecl::from_byte_array(value,three_six_three);
34  if ( debug_output ) { std::cout << "value: " << value << std::endl; }
35  EXPECT_EQ(363,value);
36  ecl::from_byte_array(u_value,u_three_six_three);
37  if ( debug_output ) { std::cout << "value: " << u_value << std::endl; }
38  EXPECT_EQ(363,u_value);
39  ecl::from_byte_array(value,minus_two);
40  if ( debug_output ) { std::cout << "value: " << value << std::endl; }
41  EXPECT_EQ(-2,value);
42  ecl::from_byte_array(value,u_minus_two);
43  if ( debug_output ) { std::cout << "value: " << value << std::endl; }
44  EXPECT_EQ(-2,value);
45 }
46 
47 /*****************************************************************************
48 ** Main program
49 *****************************************************************************/
50 
51 int main(int argc, char **argv) {
52 
53  testing::InitGoogleTest(&argc,argv);
54  return RUN_ALL_TESTS();
55 }
int main(int argc, char **argv)
Definition: byte_array.cpp:51
void from_byte_array(int32 &value, const char *byte_array)
Converts an array of four char into a 32 bit integer.
Definition: byte_array.hpp:43
TEST(ConverterTests, byteArrays)
Definition: byte_array.cpp:26
bool debug_output
Definition: byte_array.cpp:20


ecl_converters_lite
Author(s): Daniel Stonier
autogenerated on Fri Jun 7 2019 21:52:43