00001
#include "foundation_AMOS.hh"
00002
#include <iostream>
00003
using namespace AMOS;
00004
using namespace std;
00005
00006 int main (
int argc,
char ** argv)
00007 {
00008
if ( argc != 2 )
00009 {
00010 cerr <<
"USAGE: " << argv[0] <<
" <outfile>" << endl;
00011 exit (-1);
00012 }
00013
00014
const uint8_t u8c = 0x01;
00015
const uint16_t u16c = 0x0123;
00016
const uint32_t u32c = 0x01234567;
00017
const uint64_t u64c = 0x0123456789ABCDEFull;
00018
00019
const int8_t s8c = -u8c;
00020
const int16_t s16c = -u16c;
00021
const int32_t s32c = -u32c;
00022
const int64_t s64c = -u64c;
00023
00024 cout <<
"BEFORE." << endl
00025 << (
unsigned long long)u8c << endl
00026 << (
unsigned long long)u16c << endl
00027 << (
unsigned long long)u32c << endl
00028 << (
unsigned long long)u64c << endl
00029 << (
long long)s8c << endl
00030 << (
long long)s16c << endl
00031 << (
long long)s32c << endl
00032 << (
long long)s64c << endl << endl;
00033
00034 uint8_t u8;
00035 uint16_t u16;
00036 uint32_t u32;
00037 uint64_t u64;
00038
00039 int8_t s8;
00040 int16_t s16;
00041 int32_t s32;
00042 int64_t s64;
00043
00044 fstream as;
00045 as . open (argv[1], ios::out | ios::binary | ios::trunc);
00046
writeLE (as, &u8c);
00047
writeLE (as, &u16c);
00048
writeLE (as, &u32c);
00049
writeLE (as, &u64c);
00050
writeLE (as, &s8c);
00051
writeLE (as, &s16c);
00052
writeLE (as, &s32c);
00053
writeLE (as, &s64c);
00054 as . close( );
00055
00056 as . open (argv[1], ios::in | ios::binary);
00057
readLE (as, &u8);
00058
readLE (as, &u16);
00059
readLE (as, &u32);
00060
readLE (as, &u64);
00061
readLE (as, &s8);
00062
readLE (as, &s16);
00063
readLE (as, &s32);
00064
readLE (as, &s64);
00065 as . close( );
00066
00067 cout <<
"AFTER." << endl
00068 << (
unsigned long long)u8 << endl
00069 << (
unsigned long long)u16 << endl
00070 << (
unsigned long long)u32 << endl
00071 << (
unsigned long long)u64 << endl
00072 << (
long long)s8 << endl
00073 << (
long long)s16 << endl
00074 << (
long long)s32 << endl
00075 << (
long long)s64 << endl << endl;
00076
00077
if ( u8c == u8 && u16c == u16 && u32c == u32 && u64c == u64 &&
00078 s8c == s8 && s16c == s16 && s32c == s32 && s64c == s64 )
00079 {
00080 cout <<
"SUCCESS!" << endl;
00081
return 0;
00082 }
00083
else
00084 {
00085 cout <<
"FAILURE!" << endl;
00086
return -1;
00087 }
00088 }