Newer
Older
#include "Nemesis/gtest/Gtest_Functions.hh"
#include "Nemesis/gtest/nemesis_gtest.hh"
/*******************************************************************************
* Test whether we read floats with VAX format properly
******************************************************************************/
bool is_unix = false;
double readVal;
float * dummy;
double gold;
char byte1 = 0b00000001;
char byte2 = 0b00000010;
char byte3 = 0b00000011;
char byte4 = 0b00000100;
// | | | |
int vax = 0b00000001000000010000010000000011;
// byte order 2--, 1, 4, 3
std::stringstream in;
in << byte1 << byte2 << byte3 << byte4;
readVal = odf.readFloat(in,is_unix);
dummy = (float *) &vax;
gold = *dummy;
ASSERT_EQ( readVal, gold );
}
/*******************************************************************************
* Test whether we read floats with UNIX format properly
******************************************************************************/
bool is_unix = true;
double readVal;
float * dummy;
double gold;
char byte1 = 0b00000001;
char byte2 = 0b00000010;
char byte3 = 0b00000011;
char byte4 = 0b00000100;
// | | | |
int unix = 0b00000100000000110000001000000001;
std::stringstream in;
in << byte1 << byte2 << byte3 << byte4;
readVal = odf.readFloat(in,is_unix);
dummy = (float *) &unix;
gold = *dummy;
ASSERT_EQ( readVal, gold );
}
/*******************************************************************************
* Test whether we read integers right
******************************************************************************/
char byte1 = 0b00000001;
char byte2 = 0b00000010;
char byte3 = 0b00000011;
char byte4 = 0b00000100;
std::stringstream in;
in << byte4 << byte3 << byte2 << byte1;