diff options
author | Hubert Jarosz <marqin.pl@gmail.com> | 2016-03-09 00:00:52 +0100 |
---|---|---|
committer | Hubert Jarosz <marqin.pl@gmail.com> | 2016-03-09 00:00:52 +0100 |
commit | 4a4f2479146aa33e235ed57cde311efda68d3c8f (patch) | |
tree | cf91f2869ff8f058c6682569fb31e22e5ee736ad /bin/tests | |
parent | 1dad6eca812e5c2e313b54265114de8a1d73d999 (diff) |
remove trailing whitespace
Diffstat (limited to 'bin/tests')
-rw-r--r-- | bin/tests/test_containers.cpp | 22 | ||||
-rw-r--r-- | bin/tests/test_detailer.cpp | 30 | ||||
-rw-r--r-- | bin/tests/test_gdscript.cpp | 2 | ||||
-rw-r--r-- | bin/tests/test_gui.cpp | 56 | ||||
-rw-r--r-- | bin/tests/test_io.cpp | 22 | ||||
-rw-r--r-- | bin/tests/test_main.cpp | 32 | ||||
-rw-r--r-- | bin/tests/test_math.cpp | 2 | ||||
-rw-r--r-- | bin/tests/test_particles.cpp | 32 | ||||
-rw-r--r-- | bin/tests/test_physics.cpp | 60 | ||||
-rw-r--r-- | bin/tests/test_python.cpp | 2 | ||||
-rw-r--r-- | bin/tests/test_render.cpp | 40 | ||||
-rw-r--r-- | bin/tests/test_shader_lang.cpp | 2 | ||||
-rw-r--r-- | bin/tests/test_string.cpp | 328 |
13 files changed, 315 insertions, 315 deletions
diff --git a/bin/tests/test_containers.cpp b/bin/tests/test_containers.cpp index f8cc8ccd41..4bc297d0ba 100644 --- a/bin/tests/test_containers.cpp +++ b/bin/tests/test_containers.cpp @@ -44,9 +44,9 @@ MainLoop * test() { /* HashMap<int,int> int_map; - + for (int i=0;i<68000;i++) { - + int num=(int)Math::random(0,1024); int_map[i]=num; } @@ -70,21 +70,21 @@ MainLoop * test() { }; }; - -#if 0 + +#if 0 Set<int> set; - + print_line("Begin Insert"); for (int i=0;i<1100;i++) { - + int num=i;//(int)Math::random(0,1024); - // print_line("inserting "+itos(num)); + // print_line("inserting "+itos(num)); set.insert( num ); } - + /* for (int i=0;i<400;i++) { - + int num=(int)Math::random(0,1024); set.erase(num); } @@ -92,11 +92,11 @@ MainLoop * test() { //set.print_tree(); for(Set<int>::Element *I=set.front();I;I=I->next()) { - + print_line("inserted "+itos(I->get())+" prev is "+itos(I->prev()?I->prev()->get():-100)); } - + print_line("depth is "+itos(set.calculate_depth())); print_line("Insert Success"); #endif diff --git a/bin/tests/test_detailer.cpp b/bin/tests/test_detailer.cpp index 616356077e..5dba7c3f72 100644 --- a/bin/tests/test_detailer.cpp +++ b/bin/tests/test_detailer.cpp @@ -44,7 +44,7 @@ class TestMainLoop : public MainLoop { RID light; RID mesh; RID scenario; - + #define MULTIMESH_COUNT 1500 float ofs_x,ofs_y; @@ -122,9 +122,9 @@ public: } virtual void input_event(const InputEvent& p_event) { - + if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&4) { - + ofs_x+=p_event.mouse_motion.relative_y/200.0; ofs_y+=p_event.mouse_motion.relative_x/200.0; } @@ -142,16 +142,16 @@ public: } - + virtual void request_quit() { - + quit=true; } virtual void init() { - + VisualServer *vs=VisualServer::get_singleton(); @@ -163,13 +163,13 @@ public: _update_qh(); instance = vs->instance_create2(mesh,scenario); - + camera = vs->camera_create(); - + vs->camera_set_perspective( camera, 60.0,0.1, 100.0 ); viewport = vs->viewport_create(); - vs->viewport_attach_camera( viewport, camera ); + vs->viewport_attach_camera( viewport, camera ); vs->viewport_attach_to_screen(viewport); vs->viewport_set_scenario( viewport, scenario ); @@ -179,7 +179,7 @@ public: //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.3,0.3,0.3) ); light = vs->instance_create2( lightaux,scenario ); vs->instance_set_transform(light,Transform(Matrix3(Vector3(0.1,0.4,0.7).normalized(),0.9))); - + ofs_x=0; ofs_y=0; quit=false; @@ -190,20 +190,20 @@ public: } virtual bool iteration(float p_time) { - + VisualServer *vs=VisualServer::get_singleton(); - + Transform tr_camera; tr_camera.rotate( Vector3(0,1,0), ofs_y ); tr_camera.rotate( Vector3(1,0,0),ofs_x ); tr_camera.translate(0,0,10); - + vs->camera_set_transform( camera, tr_camera ); - + return quit; } virtual void finish() { - + } }; diff --git a/bin/tests/test_gdscript.cpp b/bin/tests/test_gdscript.cpp index 683191fba2..4578f5aa02 100644 --- a/bin/tests/test_gdscript.cpp +++ b/bin/tests/test_gdscript.cpp @@ -81,7 +81,7 @@ static String _parser_expr(const GDParser::Node *p_expr) { case GDParser::Node::TYPE_IDENTIFIER: { - const GDParser::IdentifierNode *id_node = static_cast<const GDParser::IdentifierNode *>(p_expr); + const GDParser::IdentifierNode *id_node = static_cast<const GDParser::IdentifierNode *>(p_expr); txt=id_node->name; } break; case GDParser::Node::TYPE_CONSTANT: { diff --git a/bin/tests/test_gui.cpp b/bin/tests/test_gui.cpp index cba488a3da..f4341fd7b3 100644 --- a/bin/tests/test_gui.cpp +++ b/bin/tests/test_gui.cpp @@ -62,16 +62,16 @@ class TestMainLoop : public SceneTree { Control *control; - + public: virtual void request_quit() { - + quit(); - + } virtual void init() { - + SceneTree::init(); @@ -112,7 +112,7 @@ public: Ref<Theme> t = memnew( Theme ); frame->set_theme(t); - + get_root()->add_child( frame ); Label *label = memnew( Label ); @@ -198,21 +198,21 @@ public: //root->add_child( control ); - + LineEdit *line_edit = memnew( LineEdit ); - + line_edit->set_pos( Point2( 30,190 ) ); line_edit->set_size( Point2( 180,1 ) ); - + frame->add_child(line_edit); - + HScrollBar *hscroll = memnew( HScrollBar ); - + hscroll->set_pos( Point2( 30,290 ) ); hscroll->set_size( Point2( 180,1 ) ); hscroll->set_max(10); hscroll->set_page(4); - + frame->add_child(hscroll); @@ -234,36 +234,36 @@ public: hscroll->share(progress); MenuButton *menu_button = memnew( MenuButton ); - + menu_button->set_text("I'm a menu!"); menu_button->set_pos( Point2( 30,380 ) ); menu_button->set_size( Point2( 1,1 ) ); - - frame->add_child(menu_button); - + + frame->add_child(menu_button); + PopupMenu *popup = menu_button->get_popup(); - + popup->add_item("Hello, testing"); popup->add_item("My Dearest"); popup->add_separator(); popup->add_item("Popup"); popup->add_check_item("Check Popup"); - popup->set_item_checked(4,true); - + popup->set_item_checked(4,true); + OptionButton *options = memnew( OptionButton ); - + options->add_item("Hello, testing"); options->add_item("My Dearest"); - + options->set_pos( Point2( 230,180 ) ); options->set_size( Point2( 1,1 ) ); - - frame->add_child(options); + + frame->add_child(options); /* Tree * tree = memnew( Tree ); tree->set_columns(2); - + tree->set_pos( Point2( 230,210 ) ); tree->set_size( Point2( 150,250 ) ); @@ -286,7 +286,7 @@ public: item->set_editable(0,true); item->set_text(0,"Have,Many,Several,Options!"); item->set_range(0,2); - + frame->add_child(tree); */ @@ -365,11 +365,11 @@ public: tabc->add_child(ctl); frame->add_child(tabc); - + tabc->set_pos( Point2( 400,210 ) ); tabc->set_size( Point2( 180,250 ) ); - + Ref<ImageTexture> text = memnew( ImageTexture ); text->load("test_data/concave.png"); @@ -387,13 +387,13 @@ public: } - + }; MainLoop* test() { - + return memnew( TestMainLoop ); } diff --git a/bin/tests/test_io.cpp b/bin/tests/test_io.cpp index a1eb2be19b..a8e8d7d0fd 100644 --- a/bin/tests/test_io.cpp +++ b/bin/tests/test_io.cpp @@ -47,37 +47,37 @@ namespace TestIO { class TestMainLoop : public MainLoop { - - + + bool quit; - + public: virtual void input_event(const InputEvent& p_event) { - - + + } virtual bool idle(float p_time) { return false; } virtual void request_quit() { - + quit=true; - + } virtual void init() { quit=true; } virtual bool iteration(float p_time) { - + return quit; } virtual void finish() { - + } - - + + }; diff --git a/bin/tests/test_main.cpp b/bin/tests/test_main.cpp index 8143a95d66..363aede96e 100644 --- a/bin/tests/test_main.cpp +++ b/bin/tests/test_main.cpp @@ -64,7 +64,7 @@ const char ** tests_get_names() { "physics", NULL }; - + return test_names; } @@ -72,22 +72,22 @@ MainLoop* test_main(String p_test,const List<String>& p_args) { if (p_test=="string") { - + return TestString::test(); } - + if (p_test=="containers") { - + return TestContainers::test(); } - + if (p_test=="math") { - + return TestMath::test(); } - + if (p_test=="physics") { - + return TestPhysics::test(); } @@ -97,15 +97,15 @@ MainLoop* test_main(String p_test,const List<String>& p_args) { } if (p_test=="misc") { - + return TestMisc::test(); } if (p_test=="render") { - + return TestRender::test(); } - + #ifndef _3D_DISABLED if (p_test=="gui") { @@ -119,17 +119,17 @@ MainLoop* test_main(String p_test,const List<String>& p_args) { } if (p_test=="io") { - + return TestIO::test(); } - + if (p_test=="particles") { return TestParticles::test(); } - + if (p_test=="multimesh") { - + return TestMultiMesh::test(); } @@ -171,7 +171,7 @@ MainLoop* test_main(String p_test,const List<String>& p_args) { #ifdef PYTHON_ENABLED if (p_test=="python") { - + return TestPython::test(); } #endif diff --git a/bin/tests/test_math.cpp b/bin/tests/test_math.cpp index 05acd5c1ec..22d14ada34 100644 --- a/bin/tests/test_math.cpp +++ b/bin/tests/test_math.cpp @@ -70,7 +70,7 @@ fix: 0, 0, 49.949951, 50 v0: 0, 0, 100, 100 v1: 0, 0, 100, 100 fix: 0, 0, 100, 100 -*/ +*/ } diff --git a/bin/tests/test_particles.cpp b/bin/tests/test_particles.cpp index bafd78eda0..23a4b9e635 100644 --- a/bin/tests/test_particles.cpp +++ b/bin/tests/test_particles.cpp @@ -43,38 +43,38 @@ class TestMainLoop : public MainLoop { RID viewport; RID light; RID scenario; - + struct InstanceInfo { - + RID instance; Transform base; Vector3 rot_axis; }; - + List<InstanceInfo> instances; - + float ofs; bool quit; public: virtual void input_event(const InputEvent& p_event) { - - + + } virtual void request_quit() { - + quit=true; } virtual void init() { - + VisualServer *vs=VisualServer::get_singleton(); particles = vs->particles_create(); vs->particles_set_amount(particles,1000); - + instance = vs->instance_create2(particles,scenario); - - + + camera = vs->camera_create(); - + // vs->camera_set_perspective( camera, 60.0,0.1, 100.0 ); viewport = vs->viewport_create(); vs->viewport_attach_camera( viewport, camera ); @@ -89,7 +89,7 @@ public: RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL ); // vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) ); light = vs->instance_create2( lightaux, scenario ); - + ofs=0; quit=false; } @@ -99,14 +99,14 @@ public: virtual bool iteration(float p_time) { - + // VisualServer *vs=VisualServer::get_singleton(); - + ofs+=p_time; return quit; } virtual void finish() { - + } }; diff --git a/bin/tests/test_physics.cpp b/bin/tests/test_physics.cpp index ce96f37f3f..ecd90a13d4 100644 --- a/bin/tests/test_physics.cpp +++ b/bin/tests/test_physics.cpp @@ -47,7 +47,7 @@ class TestPhysicsMainLoop : public MainLoop { }; RID test_cube; - + RID plane; RID sphere; RID light; @@ -74,13 +74,13 @@ class TestPhysicsMainLoop : public MainLoop { //t.basis.scale( Vector3(1.0,0.5,0.2) ); vs->instance_set_transform(p_visual_instance,t); } - + bool quit; - + protected: static void _bind_methods() { - + ObjectTypeDB::bind_method("body_changed_transform",&TestPhysicsMainLoop::body_changed_transform); } @@ -90,11 +90,11 @@ protected: PhysicsServer * ps = PhysicsServer::get_singleton(); RID mesh_instance = vs->instance_create2(type_mesh_map[p_shape],scenario); - RID body = ps->body_create(p_body,!p_active_default); + RID body = ps->body_create(p_body,!p_active_default); ps->body_set_space(body,space); ps->body_set_param(body,PhysicsServer::BODY_PARAM_BOUNCE,0.0); //todo set space - ps->body_add_shape(body,type_shape_map[p_shape]); + ps->body_add_shape(body,type_shape_map[p_shape]); ps->body_set_force_integration_callback(body,this,"body_changed_transform",mesh_instance); ps->body_set_state( body, PhysicsServer::BODY_STATE_TRANSFORM,p_location); @@ -289,7 +289,7 @@ protected: public: virtual void input_event(const InputEvent& p_event) { - + if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&4) { ofs_y-=p_event.mouse_motion.relative_y/200.0; @@ -329,7 +329,7 @@ public: } virtual void request_quit() { - + quit=true; } virtual void init() { @@ -388,53 +388,53 @@ public: /* Make Trimesh */ quit=false; return; - + #if 0 #define GRID_SIZE 5 - + float grid[GRID_SIZE][GRID_SIZE]; - + for (int i=0;i<GRID_SIZE;i++) { - + for (int j=0;j<GRID_SIZE;j++) { - + grid[j][i]=Math::random(0.0, 1.0 ); } } - + Vector<Vector3> faces; - + for (int i=1;i<GRID_SIZE;i++) { - + for (int j=1;j<GRID_SIZE;j++) { - - + + #define MAKE_VERTEX(m_x,m_z)\ faces.push_back( Vector3( m_x-GRID_SIZE/2.0, grid[m_x][m_z], m_z-GRID_SIZE/2.0 )*3.0 ) - + MAKE_VERTEX(i,j-1); MAKE_VERTEX(i,j); MAKE_VERTEX(i-1,j); - + MAKE_VERTEX(i-1,j-1); MAKE_VERTEX(i,j-1); MAKE_VERTEX(i-1,j); - + } } /* - faces.clear(); + faces.clear(); faces.push_back( Vector3(0,0,-5) ); faces.push_back( Vector3(1,0,-1) ); faces.push_back( Vector3(-1,-0,-1) ); */ - + RID trimesh_shape = ps->shape_create(); ps->shape_set_data(trimesh_shape, PhysicsServer::SHAPE_CONCAVE_POLYGON,faces); faces=ps->shape_get_shape(trimesh_shape, 0); Vector<Vector3> normals; // for drawing for (int i=0;i<faces.size()/3;i++) { - + Plane p( faces[i*3+0],faces[i*3+1], faces[i*3+2] ); normals.push_back(p.normal); normals.push_back(p.normal); @@ -448,11 +448,11 @@ public: RID trimesh_mat = vs->fixed_material_create(); vs->material_generate( trimesh_mat, Color(1.0,0.5,0.3) ); vs->mesh_surface_set_material( trimesh_mesh, 0, trimesh_mat ); - + RID triins = vs->instance_create2(trimesh_mesh); - - - + + + RID tribody = ps->body_create( PhysicsServer::BODY_MODE_STATIC, trimesh_shape); Transform tritrans = Transform( Matrix3(), Vector3(0,0,-2) ); ps->body_set_state( tribody, PhysicsServer::BODY_STATE_TRANSFORM, tritrans ); @@ -483,7 +483,7 @@ public: return quit; } virtual void finish() { - + } void test_joint() { @@ -599,7 +599,7 @@ public: PhysicsServer::ShapeType type=shape_idx[i%4]; //type=PhysicsServer::SHAPE_CONVEX_POLYGON; - Transform t; + Transform t; t.origin=Vector3(0.0*i,3.5+1.1*i,0.7+0.0*i); //t.origin=Vector3(-0.7+0.0*i,0.5+4.1*i,0); diff --git a/bin/tests/test_python.cpp b/bin/tests/test_python.cpp index 575caf2513..26fb4bdafb 100644 --- a/bin/tests/test_python.cpp +++ b/bin/tests/test_python.cpp @@ -47,7 +47,7 @@ void test() { PyRun_SimpleString("b=Moch();\n"); PyRun_SimpleString("b.mooch();\n"); PyRun_SimpleString("b.meis();\n"); - + } diff --git a/bin/tests/test_render.cpp b/bin/tests/test_render.cpp index 568699e5e6..9c3a287afa 100644 --- a/bin/tests/test_render.cpp +++ b/bin/tests/test_render.cpp @@ -49,16 +49,16 @@ class TestMainLoop : public MainLoop { RID viewport; RID light; RID scenario; - + struct InstanceInfo { - + RID instance; Transform base; Vector3 rot_axis; }; - + List<InstanceInfo> instances; - + float ofs; bool quit; protected: @@ -66,13 +66,13 @@ protected: public: virtual void input_event(const InputEvent& p_event) { - + if (p_event.type==InputEvent::KEY && p_event.key.pressed) quit=true; } virtual void init() { - + print_line("INITIALIZING TEST RENDER"); VisualServer *vs=VisualServer::get_singleton(); @@ -150,26 +150,26 @@ public: }; for (int i=0;i<object_count;i++) { - + InstanceInfo ii; - - + + ii.instance = vs->instance_create2( test_cube, scenario ); - - + + ii.base.translate( Math::random(-20,20), Math::random(-20,20),Math::random(-20,18) ); ii.base.rotate( Vector3(0,1,0), Math::randf() * Math_PI ); ii.base.rotate( Vector3(1,0,0), Math::randf() * Math_PI ); - vs->instance_set_transform( ii.instance, ii.base ); - + vs->instance_set_transform( ii.instance, ii.base ); + ii.rot_axis = Vector3( Math::random(-1,1), Math::random(-1,1), Math::random(-1,1) ).normalized(); - + instances.push_back(ii); - + } - + camera = vs->camera_create(); - + // vs->camera_set_perspective( camera, 60.0,0.1, 100.0 ); viewport = vs->viewport_create(); @@ -226,9 +226,9 @@ public: ofs+=p_time*0.05; //return quit; - + for(List<InstanceInfo>::Element *E=instances.front();E;E=E->next()) { - + Transform pre( Matrix3(E->get().rot_axis, ofs), Vector3() ); vs->instance_set_transform( E->get().instance, pre * E->get().base ); /* @@ -238,7 +238,7 @@ public: instances.erase(E ); }*/ } - + return quit; } diff --git a/bin/tests/test_shader_lang.cpp b/bin/tests/test_shader_lang.cpp index e55ad3074f..9c0075c47d 100644 --- a/bin/tests/test_shader_lang.cpp +++ b/bin/tests/test_shader_lang.cpp @@ -290,7 +290,7 @@ MainLoop* test() { FileAccess *fa = FileAccess::open(test,FileAccess::READ); - if (!fa) { + if (!fa) { ERR_FAIL_V(NULL); } diff --git a/bin/tests/test_string.cpp b/bin/tests/test_string.cpp index 27707b1a00..be37ce118f 100644 --- a/bin/tests/test_string.cpp +++ b/bin/tests/test_string.cpp @@ -38,145 +38,145 @@ namespace TestString { bool test_1() { - + OS::get_singleton()->print("\n\nTest 1: Assign from cstr\n"); - + String s = "Hello"; - + OS::get_singleton()->print("\tExpected: Hello\n"); OS::get_singleton()->print("\tResulted: %ls\n",s.c_str()); - + return (wcscmp(s.c_str(),L"Hello")==0); - + } bool test_2() { - + OS::get_singleton()->print("\n\nTest 2: Assign from string (operator=)\n"); - + String s = "Dolly"; String t = s; - + OS::get_singleton()->print("\tExpected: Dolly\n"); OS::get_singleton()->print("\tResulted: %ls\n",t.c_str()); - + return (wcscmp(t.c_str(),L"Dolly")==0); - + } bool test_3() { - + OS::get_singleton()->print("\n\nTest 3: Assign from c-string (copycon)\n"); - + String s("Sheep"); String t(s); - + OS::get_singleton()->print("\tExpected: Sheep\n"); OS::get_singleton()->print("\tResulted: %ls\n",t.c_str()); - + return (wcscmp(t.c_str(),L"Sheep")==0); - + } bool test_4() { - + OS::get_singleton()->print("\n\nTest 4: Assign from c-widechar (operator=)\n"); - + String s(L"Give me"); - + OS::get_singleton()->print("\tExpected: Give me\n"); OS::get_singleton()->print("\tResulted: %ls\n",s.c_str()); - + return (wcscmp(s.c_str(),L"Give me")==0); - + } bool test_5() { - + OS::get_singleton()->print("\n\nTest 5: Assign from c-widechar (copycon)\n"); - + String s(L"Wool"); - + OS::get_singleton()->print("\tExpected: Wool\n"); OS::get_singleton()->print("\tResulted: %ls\n",s.c_str()); - + return (wcscmp(s.c_str(),L"Wool")==0); - + } bool test_6() { - + OS::get_singleton()->print("\n\nTest 6: comparisons (equal)\n"); - - + + String s="Test Compare"; - + OS::get_singleton()->print("\tComparing to \"Test Compare\"\n"); - + if (! ( s=="Test Compare" ) ) return false; - + if (! ( s==L"Test Compare" ) ) return false; - + if (! ( s==String("Test Compare") ) ) return false; - + return true; - + } bool test_7() { - + OS::get_singleton()->print("\n\nTest 7: comparisons (unequal)\n"); - - + + String s="Test Compare"; - + OS::get_singleton()->print("\tComparing to \"Test Compare\"\n"); - + if (! ( s!="Peanut" ) ) return false; - + if (! ( s!=L"Coconut" ) ) return false; - + if (! ( s!=String("Butter") ) ) return false; - + return true; - + } bool test_8() { - + OS::get_singleton()->print("\n\nTest 8: comparisons (operator<)\n"); - - + + String s="Bees"; - + OS::get_singleton()->print("\tComparing to \"Bees\"\n"); - + if ( ! (s < "Elephant") ) return false; - + if ( s < L"Amber" ) return false; - + if ( s < String("Beatrix") ) return false; - + return true; - + } bool test_9() { - + OS::get_singleton()->print("\n\nTest 9: Concatenation\n"); - - + + String s; - + s+="Have"; s+=' '; s+='a'; @@ -184,279 +184,279 @@ bool test_9() { s = s + L"Nice"; s = s + " "; s = s + String("Day"); - + OS::get_singleton()->print("\tComparing to \"Have a Nice Day\"\n"); - + return (s == "Have a Nice Day"); - + } bool test_10() { - + OS::get_singleton()->print("\n\nTest 10: Misc funcs (size/length/empty/etc)\n"); - + if (! String("").empty()) return false; - + if (String("Mellon").size() != 7) return false; if (String("Oranges").length() != 7) return false; - + return true; - + } bool test_11() { - + OS::get_singleton()->print("\n\nTest 11: Operator[]\n"); - + String a="Kugar Sane"; - + a[0]='S'; a[6]='C'; - + if (a != "Sugar Cane") return false; - + if (a[1]!='u') return false; - + return true; - + } bool test_12() { - + OS::get_singleton()->print("\n\nTest 12: case functions\n"); - - + + String a="MoMoNgA"; - + if (a.to_upper() != "MOMONGA") return false; - + if (a.nocasecmp_to("momonga")!=0) return false; - + return true; - + } bool test_13() { - + OS::get_singleton()->print("\n\nTest 13: UTF8\n"); - + /* how can i embed UTF in here? */ - + static const CharType ustr[] = { 0x304A , 0x360F, 0x3088, 0x3046, 0 }; // static const wchar_t ustr[] = { 'P', 0xCE, 'p',0xD3, 0 }; String s=ustr; - + OS::get_singleton()->print("\tUnicode: %ls\n",ustr); s.parse_utf8( s.utf8().get_data() ); OS::get_singleton()->print("\tConvert/Parse UTF8: %ls\n",s.c_str()); - + return (s==ustr); - + } bool test_14() { - + OS::get_singleton()->print("\n\nTest 14: ASCII\n"); - + String s = L"Primero Leche"; OS::get_singleton()->print("\tAscii: %s\n",s.ascii().get_data()); - + String t=s.ascii().get_data(); return (s==t); - + } bool test_15() { - + OS::get_singleton()->print("\n\nTest 15: substr\n"); - + String s="Killer Baby"; OS::get_singleton()->print("\tsubstr(3,4) of \"%ls\" is \"%ls\"\n",s.c_str(),s.substr(3,4).c_str()); - + return (s.substr(3,4)=="ler "); - + } bool test_16() { - + OS::get_singleton()->print("\n\nTest 16: find\n"); - + String s="Pretty Woman"; OS::get_singleton()->print("\tString: %ls\n",s.c_str()); OS::get_singleton()->print("\t\"tty\" is at %i pos.\n",s.find("tty")); OS::get_singleton()->print("\t\"Revenge of the Monster Truck\" is at %i pos.\n",s.find("Revenge of the Monster Truck")); - + if (s.find("tty")!=3) return false; - + if (s.find("Revenge of the Monster Truck")!=-1) return false; - + return true; - + } bool test_17() { - + OS::get_singleton()->print("\n\nTest 17: find no case\n"); - + String s="Pretty Whale"; OS::get_singleton()->print("\tString: %ls\n",s.c_str()); OS::get_singleton()->print("\t\"WHA\" is at %i pos.\n",s.findn("WHA")); OS::get_singleton()->print("\t\"Revenge of the Monster SawFish\" is at %i pos.\n",s.findn("Revenge of the Monster Truck")); - + if (s.findn("WHA")!=7) return false; - + if (s.findn("Revenge of the Monster SawFish")!=-1) return false; - + return true; - + } bool test_18() { - + OS::get_singleton()->print("\n\nTest 18: find no case\n"); - + String s="Pretty Whale"; OS::get_singleton()->print("\tString: %ls\n",s.c_str()); OS::get_singleton()->print("\t\"WHA\" is at %i pos.\n",s.findn("WHA")); OS::get_singleton()->print("\t\"Revenge of the Monster SawFish\" is at %i pos.\n",s.findn("Revenge of the Monster Truck")); - + if (s.findn("WHA")!=7) return false; - + if (s.findn("Revenge of the Monster SawFish")!=-1) return false; - + return true; - + } bool test_19() { - + OS::get_singleton()->print("\n\nTest 19: Search & replace\n"); - + String s="Happy Birthday, Anna!"; OS::get_singleton()->print("\tString: %ls\n",s.c_str()); - + s=s.replace("Birthday","Halloween"); OS::get_singleton()->print("\tReplaced Birthday/Halloween: %ls.\n",s.c_str()); - + return (s=="Happy Halloween, Anna!"); - + } bool test_20() { - + OS::get_singleton()->print("\n\nTest 20: Insertion\n"); - + String s="Who is Frederic?"; - + OS::get_singleton()->print("\tString: %ls\n",s.c_str()); s=s.insert( s.find("?")," Chopin" ); OS::get_singleton()->print("\tInserted Chopin: %ls.\n",s.c_str()); - + return (s=="Who is Frederic Chopin?"); - + } bool test_21() { - + OS::get_singleton()->print("\n\nTest 21: Number -> String\n"); - + OS::get_singleton()->print("\tPi is %f\n",33.141593); OS::get_singleton()->print("\tPi String is %ls\n",String::num(3.141593).c_str()); - + return String::num(3.141593)=="3.141593"; - + } bool test_22() { - + OS::get_singleton()->print("\n\nTest 22: String -> Int\n"); - + static const char* nums[4]={ "1237461283", "- 22", "0", " - 1123412" }; static const int num[4]={ 1237461283, -22, 0, -1123412 }; - + for (int i=0;i<4;i++) { OS::get_singleton()->print("\tString: \"%s\" as Int is %i\n",nums[i],String(nums[i]).to_int()); - + if (String(nums[i]).to_int()!=num[i]) return false; } - + return true; - + } bool test_23() { - + OS::get_singleton()->print("\n\nTest 23: String -> Float\n"); - + static const char* nums[4]={ "-12348298412.2", "0.05", "2.0002", " -0.0001" }; static const double num[4]={ -12348298412.2, 0.05, 2.0002, -0.0001 }; - + for (int i=0;i<4;i++) { OS::get_singleton()->print("\tString: \"%s\" as Float is %f\n",nums[i],String(nums[i]).to_double()); - + if ( ABS(String(nums[i]).to_double()-num[i])>0.00001) return false; } - + return true; - + } bool test_24() { - + OS::get_singleton()->print("\n\nTest 24: Slicing\n"); - + String s="Mars,Jupiter,Saturn,Uranus"; - + const char*slices[4]={"Mars","Jupiter","Saturn","Uranus"}; - + OS::get_singleton()->print("\tSlicing \"%ls\" by \"%s\"..\n",s.c_str(),","); - + for (int i=0;i<s.get_slice_count(",");i++) { - + OS::get_singleton()->print("\t\t%i- %ls\n",i+1,s.get_slice(",",i).c_str()); - - + + if (s.get_slice(",",i)!=slices[i]) return false; } - + return true; - + } bool test_25() { - + OS::get_singleton()->print("\n\nTest 25: Erasing\n"); - + String s="Josephine is such a cute girl!"; - + OS::get_singleton()->print("\tString: %ls\n",s.c_str()); OS::get_singleton()->print("\tRemoving \"cute\"\n"); - + s.erase(s.find("cute "),String("cute ").length()); OS::get_singleton()->print("\tResult: %ls\n",s.c_str()); - - + + return (s=="Josephine is such a girl!"); - + } bool test_26() { @@ -516,7 +516,7 @@ bool test_28() { String format, output; Array args; bool error; - + // %% format = "fish %% frog"; args.clear(); @@ -846,7 +846,7 @@ bool test_28() { typedef bool (*TestFunc)(void); TestFunc test_funcs[] = { - + test_1, test_2, test_3, @@ -876,18 +876,18 @@ TestFunc test_funcs[] = { test_27, test_28, 0 - + }; MainLoop* test() { - + /** A character length != wchar_t may be forced, so the tests wont work */ - + ERR_FAIL_COND_V( sizeof(CharType) != sizeof(wchar_t), NULL ); - + int count=0; int passed=0; - + while(true) { if (!test_funcs[count]) break; @@ -895,17 +895,17 @@ MainLoop* test() { if (pass) passed++; OS::get_singleton()->print("\t%s\n",pass?"PASS":"FAILED"); - + count++; } - + OS::get_singleton()->print("\n\n\n"); OS::get_singleton()->print("*************\n"); OS::get_singleton()->print("***TOTALS!***\n"); OS::get_singleton()->print("*************\n"); - + OS::get_singleton()->print("Passed %i of %i tests\n", passed, count); - + return NULL; } |