Go to the documentation of this file.00001
00011
00012
00013
00014
00015 #include <iostream>
00016 #include <gtest/gtest.h>
00017 #include <ecl/formatters.hpp>
00018 #include "../../include/ecl/containers/array.hpp"
00019 #include "../../include/ecl/containers/push_and_pop.hpp"
00020 #include "../../include/ecl/containers/stencil.hpp"
00021
00022
00023
00024
00025
00026 using ecl::Array;
00027 using ecl::Format;
00028 using ecl::Hex;
00029 using ecl::NoAlign;
00030 using ecl::Stencil;
00031
00032
00033
00034
00035
00036 int main(int argc, char **argv) {
00037
00038 std::cout << std::endl;
00039 std::cout << "***********************************************************" << std::endl;
00040 std::cout << " Arrays" << std::endl;
00041 std::cout << "***********************************************************" << std::endl;
00042 std::cout << std::endl;
00043
00044 Array<int,4> int_array;
00045 int_array << 1,2,3,4;
00046 Array<float,4> float_array;
00047 float_array << 1,2,3.32235,-324;
00048 Format< Array<int,4> > format_array;
00049
00050 Array<float,4>::Formatter format_array_float;
00051 format_array_float.precision(3);
00052 std::cout << format_array(int_array) << std::endl;
00053 std::cout << format_array_float(float_array) << std::endl;
00054
00055 std::cout << std::endl;
00056 std::cout << "***********************************************************" << std::endl;
00057 std::cout << " Dynamic Arrays" << std::endl;
00058 std::cout << "***********************************************************" << std::endl;
00059 std::cout << std::endl;
00060
00061 Array<float> float_array_dynamic(4);
00062 Format< Array<float> > format_array_dynamic_float;
00063 format_array_dynamic_float.precision(3);
00064 float_array_dynamic << 1,2,3.32235,-324;
00065 std::cout << format_array_dynamic_float(float_array_dynamic) << std::endl;
00066
00067 std::cout << std::endl;
00068 std::cout << "***********************************************************" << std::endl;
00069 std::cout << " Float Stencils" << std::endl;
00070 std::cout << "***********************************************************" << std::endl;
00071 std::cout << std::endl;
00072
00073 Array<float> float_array_under(20);
00074 float_array_under << 1,2,3.32235,-324;
00075 Format< Stencil< Array<float> > > format_stencil;
00076 format_stencil.precision(3);
00077 std::cout << format_stencil(float_array_under.stencil(1,2)) << std::endl;
00078 Array<double> double_array_under(20);
00079 double_array_under << 1,2,3.32235,-324;
00080 Format< Stencil< Array<double> > > format_double_stencil;
00081 format_double_stencil.precision(3);
00082 std::cout << format_double_stencil(double_array_under.stencil(1,2)) << std::endl;
00083
00084 std::cout << std::endl;
00085 std::cout << "***********************************************************" << std::endl;
00086 std::cout << " Byte Arrays" << std::endl;
00087 std::cout << "***********************************************************" << std::endl;
00088 std::cout << std::endl;
00089
00090 Array<signed char,4> schar_array;
00091 schar_array << 'a','b','c','d';
00092 Format< Array<signed char,4> > format_sbytes;
00093 std::cout << schar_array << std::endl;
00094 std::cout << format_sbytes(schar_array) << std::endl;
00095 std::cout << format_sbytes(schar_array.stencil(0,2)) << std::endl;
00096 Array<char,4> char_array;
00097 char_array << 'a','b','c','d';
00098 Array<char,4>::Formatter format_bytes;
00099
00100 std::cout << char_array << std::endl;
00101 std::cout << format_bytes(char_array) << std::endl;
00102 std::cout << format_bytes(char_array.stencil(0,2)) << std::endl;
00103 Array<unsigned char,4> uchar_array;
00104 uchar_array << 0x01, 0x02, 0x03, 0x04;
00105 Format< Array<unsigned char,4> > format_ubytes;
00106 Format<unsigned char> format_uchar(-1,NoAlign,Hex);
00107 std::cout << "[ ";
00108 for ( unsigned int i = 0; i < uchar_array.size(); ++i ) {
00109 std::cout << format_uchar(uchar_array[i]) << " ";
00110 }
00111 std::cout << "]" << std::endl;
00112 std::cout << format_ubytes(uchar_array) << std::endl;
00113 std::cout << format_ubytes(uchar_array.stencil(0,2)) << std::endl;
00114
00115 ecl::PushAndPop<unsigned char> push_and_pop;
00116 push_and_pop.resize(4);
00117 push_and_pop.push_back(0xaa);
00118 push_and_pop.push_back(0x55);
00119 ecl::PushAndPop<unsigned char>::Formatter format;
00120 std::cout << format(push_and_pop) << std::endl;
00121
00122 std::cout << std::endl;
00123 std::cout << "***********************************************************" << std::endl;
00124 std::cout << " Passed" << std::endl;
00125 std::cout << "***********************************************************" << std::endl;
00126 std::cout << std::endl;
00127 return 0;
00128 }
00129