X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftrunk%2Ftest%2Fvalue.cpp;h=b5906d641021c72e6647c3b8a7c7d7822e41fa77;hb=cee5940bae97612105db8b7e1ffcf513f9d9150c;hp=e5f4ae2c0654bc81fd06044431509613f31ec79f;hpb=dee84efa006428fdfbf0e84b66ee94eb23113ad9;p=synfig.git diff --git a/ETL/trunk/test/value.cpp b/ETL/trunk/test/value.cpp index e5f4ae2..b5906d6 100644 --- a/ETL/trunk/test/value.cpp +++ b/ETL/trunk/test/value.cpp @@ -37,20 +37,20 @@ using namespace etl; struct stupidv { float x,y; - + stupidv(float xin=0, float yin=0) :x(xin),y(yin) {} void print() const { printf("(x=%f,y=%f)\n",x,y); - } + } }; struct stupidp { float z,w; - + stupidp(float zin=0, float win=0) :z(zin),w(win) {} - + void print() const { printf("(z=%f,w=%f)\n",z,w); @@ -60,60 +60,60 @@ struct stupidp template <> class etl::value_store_type { - typedef stupidv value_type; + typedef stupidv value_type; }; int main() -{ +{ try { value v(10.0); //construction value v2; //default construct... - + //get type... printf("type of 10.0: %s\n", v.type().name()); - + v2 = 1; //assignment printf("type of 1: %s\n", v2.type().name()); - + //extract int test - + int *pi = value_cast(&v2); printf("v2 is an int(%p)\n", pi); printf(" %d\n", value_cast(v2)); - + printf(" const version: %d\n", value_cast(value(5))); - + v = 'c'; //assignment again... printf("type of c: %s\n", v.type().name()); - + v2 = v; //value assignment printf("type of v2 , v: %s , %s\n", v2.type().name(), v.type().name()); - + //random type test v = stupidv(0,1); printf("type of vec: %s\n", v.type().name()); - + //type cast with binary change test value_cast(&v)->print(); value_cast(stupidp(5,10)).print(); //copy test - + printf("type of v: %s\n", v.type().name()); - printf("type of v2: %s\n", v2.type().name()); + printf("type of v2: %s\n", v2.type().name()); v.swap(v2); printf("type of v: %s\n", v.type().name()); printf("type of v2: %s\n", v2.type().name()); - + // test the exception throwing... value_cast(stupidp(6,66)); - - }catch(const etl::bad_value_cast &e) + + }catch(const etl::bad_value_cast &e) { printf(" Exploded: %s\n",e.what()); }catch(...) { printf(" Exploded\n"); } - + return 0; }