projects
/
synfig.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Typo: 'emptys' -> 'empties'.
[synfig.git]
/
ETL
/
trunk
/
test
/
value.cpp
diff --git
a/ETL/trunk/test/value.cpp
b/ETL/trunk/test/value.cpp
index
e5f4ae2
..
bf01490
100644
(file)
--- a/
ETL/trunk/test/value.cpp
+++ b/
ETL/trunk/test/value.cpp
@@
-1,7
+1,7
@@
/*! ========================================================================
** Extended Template and Library Test Suite
** Generic Value Test
/*! ========================================================================
** Extended Template and Library Test Suite
** Generic Value Test
-** $Id
: value.cpp,v 1.1.1.1 2005/01/04 01:31:48 darco Exp
$
+** $Id$
**
** Copyright (c) 2002 Adrian Bentley
**
**
** Copyright (c) 2002 Adrian Bentley
**
@@
-37,20
+37,20
@@
using namespace etl;
struct stupidv
{
float x,y;
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);
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;
};
struct stupidp
{
float z,w;
-
+
stupidp(float zin=0, float win=0) :z(zin),w(win) {}
stupidp(float zin=0, float win=0) :z(zin),w(win) {}
-
+
void print() const
{
printf("(z=%f,w=%f)\n",z,w);
void print() const
{
printf("(z=%f,w=%f)\n",z,w);
@@
-60,60
+60,60
@@
struct stupidp
template <>
class etl::value_store_type<stupidp>
{
template <>
class etl::value_store_type<stupidp>
{
- typedef stupidv value_type;
+ typedef stupidv value_type;
};
int main()
};
int main()
-{
+{
try
{
value v(10.0); //construction
value v2; //default construct...
try
{
value v(10.0); //construction
value v2; //default construct...
-
+
//get type...
printf("type of 10.0: %s\n", v.type().name());
//get type...
printf("type of 10.0: %s\n", v.type().name());
-
+
v2 = 1; //assignment
printf("type of 1: %s\n", v2.type().name());
v2 = 1; //assignment
printf("type of 1: %s\n", v2.type().name());
-
+
//extract int test
//extract int test
-
+
int *pi = value_cast<int>(&v2);
printf("v2 is an int(%p)\n", pi);
printf(" %d\n", value_cast<int>(v2));
int *pi = value_cast<int>(&v2);
printf("v2 is an int(%p)\n", pi);
printf(" %d\n", value_cast<int>(v2));
-
+
printf(" const version: %d\n", value_cast<int>(value(5)));
printf(" const version: %d\n", value_cast<int>(value(5)));
-
+
v = 'c'; //assignment again...
printf("type of c: %s\n", v.type().name());
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());
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());
//random type test
v = stupidv(0,1);
printf("type of vec: %s\n", v.type().name());
-
+
//type cast with binary change test
value_cast<stupidp>(&v)->print();
value_cast<stupidv>(stupidp(5,10)).print(); //copy test
//type cast with binary change test
value_cast<stupidp>(&v)->print();
value_cast<stupidv>(stupidp(5,10)).print(); //copy test
-
+
printf("type of v: %s\n", v.type().name());
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());
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<int>(stupidp(6,66));
// test the exception throwing...
value_cast<int>(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");
}
{
printf(" Exploded: %s\n",e.what());
}catch(...)
{
printf(" Exploded\n");
}
-
+
return 0;
}
return 0;
}