X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftrunk%2Ftest%2Fhandle.cpp;h=7d2ca11ad5a3de251ac5ae88ae2d920c8c034010;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=fd40e2557fb1ec294337f2965710b6cf1cfbf9db;hpb=117425a5858bb094f2e54af5d018499ab703b227;p=synfig.git diff --git a/ETL/trunk/test/handle.cpp b/ETL/trunk/test/handle.cpp index fd40e25..7d2ca11 100644 --- a/ETL/trunk/test/handle.cpp +++ b/ETL/trunk/test/handle.cpp @@ -1,7 +1,7 @@ /*! ======================================================================== ** Extended Template and Library Test Suite ** Handle Template Class Test -** $Id: handle.cpp,v 1.1.1.1 2005/01/04 01:31:48 darco Exp $ +** $Id$ ** ** Copyright (c) 2002 Robert B. Quattlebaum Jr. ** @@ -44,14 +44,14 @@ struct my_test_obj : public etl::rshared_object { instance_count++; } - + virtual ~my_test_obj() { if(instance_count==0) printf("Error, instance count is going past zero!\n"); instance_count--; } - + bool operator<(const my_test_obj &rhs)const { return my_id obj_handle(new my_test_obj(rand())); - if(obj_handle != obj_handle.constant()) + if(obj_handle != obj_handle.constant()) { printf("FAILED!\n"); printf(__FILE__":%d: on call to handle<>::constant().\n",__LINE__); return 1; } - + printf("PASSED\n"); return 0; @@ -136,13 +136,13 @@ int handle_general_use_test(void) { printf("handle: General-use test: "); my_test_obj::instance_count=0; - + obj_list my_list, my_other_list; int i; - + for(i=0;imy_id != 42 || b->my_id != 27) + { + printf("FAILED!\n"); + printf(__FILE__":%d: On swap (27,42) gave (%d,%d), should be (42,27).\n",__LINE__,a->my_id,b->my_id); + return 1; + } + } + my_other_list.clear(); if(my_test_obj::instance_count) { @@ -176,7 +187,7 @@ int handle_general_use_test(void) } printf("PASSED\n"); - + return 0; } @@ -191,29 +202,29 @@ int handle_general_use_test(void) int rhandle_general_use_test(void) { - - + + printf("rhandle: General-use test: "); my_test_obj::instance_count=0; - + robj_list my_list; int i; - + robj_handle obj= new my_test_obj(rand()); for(i=0;i my_item_list; for(i=0;i=2); } - + my_item_list.clear(); if(my_test_obj::instance_count) @@ -319,7 +330,7 @@ int rhandle_general_use_test(void) } printf("PASSED\n"); - + return 0; } @@ -328,13 +339,13 @@ int handle_inheritance_test(void) printf("handle: Inheritance test: "); my_test_obj::instance_count=0; my_other_test_obj::instance_count=0; - + other_obj_list my_other_list; int i; - + for(i=0;i a(new my_test_obj(27)), b(new my_test_obj(42)); + a.swap(b); + if (a->my_id != 42 || b->my_id != 27) + { + printf("FAILED!\n"); + printf(__FILE__":%d: on loose_handle swap (27,42) gave (%d,%d), should be (42,27).\n",__LINE__,a->my_id,b->my_id); + return 1; + } + } + + if(my_test_obj::instance_count!=3) { printf("FAILED!\n"); - printf(__FILE__":%d: on create/destroy, instance count=%d, should be 1.\n",__LINE__,my_test_obj::instance_count); + printf(__FILE__":%d: on create/destroy, instance count=%d, should be 3.\n",__LINE__,my_test_obj::instance_count); return 1; } @@ -448,19 +470,19 @@ int handle_cast_test() etl::handle obj; etl::handle other_obj; etl::loose_handle loose_obj; - + other_obj.spawn(); loose_obj=other_obj; - + obj=etl::handle::cast_dynamic(loose_obj); - + if(obj!=other_obj) { printf("FAILED!\n"); printf(__FILE__":%d: on handle assignment from loose_handle.\n",__LINE__); return 1; } - + printf("PASSED\n"); return 0; } @@ -477,6 +499,6 @@ int main() error+=handle_inheritance_test(); error+=loose_handle_test(); error+=rhandle_general_use_test(); - + return error; }