Changeset 369 for XIOS/trunk/src/test/test.cpp
- Timestamp:
- 10/16/12 13:04:44 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/test/test.cpp
r343 r369 8 8 #include "date.hpp" 9 9 #include "calendar_util.hpp" 10 //#include "test_enum.hpp" 11 #include "type.hpp" 12 //#include "axis.hpp" 13 //#include "field.hpp" 14 #include "declare_attribute.hpp" 15 #include "attribute_map.hpp" 16 #include "array_new.hpp" 17 #include "attribute_array.hpp" 18 #include "attribute_array_impl.hpp" 19 20 10 21 11 22 using namespace std ; … … 13 24 using namespace boost::gregorian ; 14 25 using namespace xios; 26 using namespace blitz; 27 28 class CEnum_color 29 { 30 public: 31 enum t_enum { rouge=0, vert, bleu} ; 32 static const char** getStr(void) { static const char * enumStr[] = { "rouge", "vert", "bleu" } ; return enumStr ; } 33 int getSize(void) { return 3 ; } 34 } ; 35 36 #include "enum.hpp" 37 #include "enum_impl.hpp" 38 #include "enum_ref_impl.hpp" 39 #include "attribute_enum.hpp" 40 #include "attribute_enum_impl.hpp" 41 42 template class CEnum<CEnum_color> ; 43 template class CAttributeEnum<CEnum_color> ; 44 15 45 16 46 int main(void) … … 18 48 // ptime t(time_from_string("2012-02-30 15:24")) ; 19 49 // std::cout << to_simple_string(t) << std::endl; 20 CGregorianCalendar MyCalendar("2011-03-01 00:00") ; 21 cout<<MyCalendar.getInitDate()<<endl; 22 cout<<MyCalendar.getCurrentDate()<<endl ; 23 cout<<MyCalendar.getCurrentDate()-1*Day<<endl ; 50 CGregorianCalendar MyCalendar("2011-03-01 00:00") ; 51 cout<<MyCalendar.getInitDate()<<endl; 52 cout<<MyCalendar.getCurrentDate()<<endl ; 53 cout<<MyCalendar.getCurrentDate()-1*Day<<endl ; 54 55 //CEnum<CEnum_color> MyEnum ; 56 //MyEnum.val=CEnum<CEnum_color>::rouge ; 57 58 CEnum_color::t_enum y; 59 60 CType<int> a(10) ; 61 CType<int> b ; 62 63 a=5 ; 64 b=10.5 ; 65 a=a+b ; 66 cout<<a<<endl ; 67 if (a==5) cout<<"a que coucou"<<endl ; 68 else if (a!=5) cout<<"a que pas coucou"<<endl ; 69 70 CType_ref<int> c(a); 71 cout<<c<<endl ; 72 a=3 ; 73 cout<<c<<endl ; 74 // c=b ; 75 cout<<c<<endl ; 76 b=4 ; 77 cout<<c<<endl ; 78 c.set_ref(b) ; 79 cout<<c<<endl ; 80 int x=c+c+a ; 81 cout<<x<<endl ; 82 83 // test::CAttributeTemplate<int> xx("toto") ; 84 // test::totoatt toto ; 85 // test::titiatt titi ; 86 // CAxis A ; 87 // CTest A ; 88 // CAxis B ; 89 // CField A ; 90 // cout<<xx.size()<<endl ; 91 92 CEnum<CEnum_color> color,color1 ; 93 color=CEnum<CEnum_color>::rouge ; 94 color1=color ; 95 96 if (color1==CEnum<CEnum_color>::rouge) cout<<"Rouge !!"<<endl ; 97 if (color1==color) cout<<"Rouge !!"<<endl ; 98 color=CEnum<CEnum_color>::bleu ; 99 100 if (color1==color) cout<<"Rouge !!"<<endl ; 101 102 cout<<color1.toString()<<endl ; 103 color1.fromString("vert ") ; 104 cout<<color1.toString()<<endl ; 105 106 // color1.fromString("jaune") ; 107 cout<<color1.toString()<<endl ; 108 cout<<sizeof(CEnum_color::t_enum)<<endl ; 109 110 CEnum_color::t_enum tt ; 111 tt=(CEnum_color::t_enum)1 ; 112 int ii=tt ; 113 cout<<ii<<endl ; 114 115 CAttributeEnum<CEnum_color> toto("toto",CEnum_color::rouge) ; 116 CAttributeEnum<CEnum_color> titi("titi",CEnum_color::vert) ; 117 cout<<toto.toString()<<endl ; 118 toto.fromString(" vert ") ; 119 cout<<toto.toString()<<endl ; 120 121 tt=toto ; 122 cout<<tt<<endl ; 123 cout<<titi.toString()<<endl ; 124 125 if (titi==toto) cout<<"titi==toto"<<endl ; 126 else cout<<"titi!=toto"<<endl ; 127 titi=CEnum_color::rouge ; 128 if (titi==toto) cout<<"titi==toto"<<endl ; 129 else cout<<"titi!=toto"<<endl ; 130 131 CArray<int,2> A(2,2) ; 132 CArray<int,2> B(2,2) ; 133 A=1,2,3,4 ; 134 B = 1 ; 135 B+=A ; 136 cout<<B.toString()<<endl ; 137 cout<<A.toString()<<endl ; 138 string str="(0,1) x (0,1) [4 3 2 1]" ; 139 CArray<int,2> C ; 140 CBufferOut out(B.size()) ; 141 142 B.toBuffer(out) ; 143 144 CBufferIn in(out.begin,B.size()) ; 145 C.fromBuffer(in) ; 146 147 cout<<C<<endl ; 148 149 CAttributeArray<int,2> attr("toto") ; 150 attr.resize(2,2) ; 151 attr=C ; 152 cout<<"attr "<<attr<<endl ; 153 cout<<attr.toString()<<endl ; 24 154 return 1 ; 25 155 }
Note: See TracChangeset
for help on using the changeset viewer.