byte_array.cpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Includes
00011 *****************************************************************************/
00012 
00013 #include <gtest/gtest.h>
00014 #include "../../include/ecl/converters_lite/byte_array.hpp"
00015 
00016 /*****************************************************************************
00017 ** Globals
00018 *****************************************************************************/
00019 
00020 bool debug_output = true;
00021 
00022 /*****************************************************************************
00023 ** Tests
00024 *****************************************************************************/
00025 
00026 TEST(ConverterTests,byteArrays) {
00027         ecl::int32 value;
00028         ecl::uint32 u_value;
00029         char three_six_three[4] = { 0x6b, 0x01, 0x00, 0x00 };
00030         unsigned char u_three_six_three[4] = { 0x6b, 0x01, 0x00, 0x00 };
00031         char minus_two[4] = { 0xfe, 0xff, 0xff, 0xff };
00032         unsigned char u_minus_two[4] = { 0xfe, 0xff, 0xff, 0xff };
00033         ecl::from_byte_array(value,three_six_three);
00034         if ( debug_output ) { std::cout << "value: " << value << std::endl; }
00035         EXPECT_EQ(363,value);
00036         ecl::from_byte_array(u_value,u_three_six_three);
00037         if ( debug_output ) { std::cout << "value: " << u_value << std::endl; }
00038         EXPECT_EQ(363,u_value);
00039         ecl::from_byte_array(value,minus_two);
00040         if ( debug_output ) { std::cout << "value: " << value << std::endl; }
00041         EXPECT_EQ(-2,value);
00042         ecl::from_byte_array(value,u_minus_two);
00043         if ( debug_output ) { std::cout << "value: " << value << std::endl; }
00044         EXPECT_EQ(-2,value);
00045 }
00046 
00047 /*****************************************************************************
00048 ** Main program
00049 *****************************************************************************/
00050 
00051 int main(int argc, char **argv) {
00052 
00053     testing::InitGoogleTest(&argc,argv);
00054     return RUN_ALL_TESTS();
00055 }


ecl_converters_lite
Author(s): Daniel Stonier (d.stonier@gmail.com)
autogenerated on Thu Jan 2 2014 11:11:29