diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_command_queue.h | 4 | ||||
-rw-r--r-- | tests/test_dictionary.h | 159 | ||||
-rw-r--r-- | tests/test_geometry_2d.h | 2 | ||||
-rw-r--r-- | tests/test_hashing_context.h | 165 | ||||
-rw-r--r-- | tests/test_list.h | 2 | ||||
-rw-r--r-- | tests/test_main.cpp | 3 | ||||
-rw-r--r-- | tests/test_path_3d.h | 85 | ||||
-rw-r--r-- | tests/test_physics_2d.cpp | 9 | ||||
-rw-r--r-- | tests/test_physics_3d.cpp | 15 | ||||
-rw-r--r-- | tests/test_shader_lang.cpp | 2 | ||||
-rw-r--r-- | tests/test_string.h | 35 | ||||
-rw-r--r-- | tests/test_text_server.h | 3 |
12 files changed, 459 insertions, 25 deletions
diff --git a/tests/test_command_queue.h b/tests/test_command_queue.h index b4fa63ad2b..2f0f62f5c8 100644 --- a/tests/test_command_queue.h +++ b/tests/test_command_queue.h @@ -31,14 +31,14 @@ #ifndef TEST_COMMAND_QUEUE_H #define TEST_COMMAND_QUEUE_H -#include "test_command_queue.h" - #include "core/config/project_settings.h" +#include "core/math/random_number_generator.h" #include "core/os/mutex.h" #include "core/os/os.h" #include "core/os/semaphore.h" #include "core/os/thread.h" #include "core/templates/command_queue_mt.h" +#include "test_macros.h" #if !defined(NO_THREADS) diff --git a/tests/test_dictionary.h b/tests/test_dictionary.h new file mode 100644 index 0000000000..b94cf36109 --- /dev/null +++ b/tests/test_dictionary.h @@ -0,0 +1,159 @@ +/*************************************************************************/ +/* test_dictionary.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef TEST_DICTIONARY_H +#define TEST_DICTIONARY_H + +#include "core/templates/ordered_hash_map.h" +#include "core/templates/safe_refcount.h" +#include "core/variant/dictionary.h" +#include "core/variant/variant.h" +#include "tests/test_macros.h" + +namespace TestDictionary { + +TEST_CASE("[Dictionary] Assignment using bracket notation ([])") { + Dictionary map; + map["Hello"] = 0; + CHECK(int(map["Hello"]) == 0); + map["Hello"] = 3; + CHECK(int(map["Hello"]) == 3); + map["World!"] = 4; + CHECK(int(map["World!"]) == 4); + + // Test non-string keys, since keys can be of any Variant type. + map[12345] = -5; + CHECK(int(map[12345]) == -5); + map[false] = 128; + CHECK(int(map[false]) == 128); + map[Vector2(10, 20)] = 30; + CHECK(int(map[Vector2(10, 20)]) == 30); + map[0] = 400; + CHECK(int(map[0]) == 400); + // Check that assigning 0 doesn't overwrite the value for `false`. + CHECK(int(map[false]) == 128); +} + +TEST_CASE("[Dictionary] == and != operators") { + Dictionary map1; + Dictionary map2; + CHECK(map1 != map2); + map1[1] = 3; + map2 = map1; + CHECK(map1 == map2); +} + +TEST_CASE("[Dictionary] get_key_lists()") { + Dictionary map; + List<Variant> keys; + List<Variant> *ptr = &keys; + map.get_key_list(ptr); + CHECK(keys.is_empty()); + map[1] = 3; + map.get_key_list(ptr); + CHECK(keys.size() == 1); + CHECK(int(keys[0]) == 1); + map[2] = 4; + map.get_key_list(ptr); + CHECK(keys.size() == 3); +} + +TEST_CASE("[Dictionary] get_key_at_index()") { + Dictionary map; + map[4] = 3; + Variant val = map.get_key_at_index(0); + CHECK(int(val) == 4); + map[3] = 1; + val = map.get_key_at_index(0); + CHECK(int(val) == 4); + val = map.get_key_at_index(1); + CHECK(int(val) == 3); +} + +TEST_CASE("[Dictionary] getptr()") { + Dictionary map; + map[1] = 3; + Variant *key = map.getptr(1); + CHECK(int(*key) == 3); + key = map.getptr(2); + CHECK(key == nullptr); +} + +TEST_CASE("[Dictionary] get_valid()") { + Dictionary map; + map[1] = 3; + Variant val = map.get_valid(1); + CHECK(int(val) == 3); +} +TEST_CASE("[Dictionary] get()") { + Dictionary map; + map[1] = 3; + Variant val = map.get(1, -1); + CHECK(int(val) == 3); +} + +TEST_CASE("[Dictionary] size(), empty() and clear()") { + Dictionary map; + CHECK(map.size() == 0); + CHECK(map.is_empty()); + map[1] = 3; + CHECK(map.size() == 1); + CHECK(!map.is_empty()); + map.clear(); + CHECK(map.size() == 0); + CHECK(map.is_empty()); +} + +TEST_CASE("[Dictionary] has() and has_all()") { + Dictionary map; + CHECK(map.has(1) == false); + map[1] = 3; + CHECK(map.has(1)); + Array keys; + keys.push_back(1); + CHECK(map.has_all(keys)); + keys.push_back(2); + CHECK(map.has_all(keys) == false); +} + +TEST_CASE("[Dictionary] keys() and values()") { + Dictionary map; + Array keys = map.keys(); + Array values = map.values(); + CHECK(keys.is_empty()); + CHECK(values.is_empty()); + map[1] = 3; + keys = map.keys(); + values = map.values(); + CHECK(int(keys[0]) == 1); + CHECK(int(values[0]) == 3); +} +} // namespace TestDictionary +#endif // TEST_DICTIONARY_H diff --git a/tests/test_geometry_2d.h b/tests/test_geometry_2d.h index ea02d1114f..c9313f3625 100644 --- a/tests/test_geometry_2d.h +++ b/tests/test_geometry_2d.h @@ -113,7 +113,7 @@ TEST_CASE("[Geometry2D] Polygon clockwise") { p.push_back(Vector2(1, 5)); CHECK(Geometry2D::is_polygon_clockwise(p)); - p.invert(); + p.reverse(); CHECK_FALSE(Geometry2D::is_polygon_clockwise(p)); } diff --git a/tests/test_hashing_context.h b/tests/test_hashing_context.h new file mode 100644 index 0000000000..728a5f2cfa --- /dev/null +++ b/tests/test_hashing_context.h @@ -0,0 +1,165 @@ +/*************************************************************************/ +/* test_hashing_context.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef TEST_HASHING_CONTEXT_H +#define TEST_HASHING_CONTEXT_H + +#include "core/crypto/hashing_context.h" + +#include "tests/test_macros.h" + +namespace TestHashingContext { + +TEST_CASE("[HashingContext] Default - MD5/SHA1/SHA256") { + HashingContext ctx; + + static const uint8_t md5_expected[] = { + 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e + }; + static const uint8_t sha1_expected[] = { + 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, + 0xaf, 0xd8, 0x07, 0x09 + }; + static const uint8_t sha256_expected[] = { + 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, + 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55 + }; + + CHECK(ctx.start(HashingContext::HASH_MD5) == OK); + PackedByteArray result = ctx.finish(); + REQUIRE(result.size() == 16); + CHECK(memcmp(result.ptr(), md5_expected, 16) == 0); + + CHECK(ctx.start(HashingContext::HASH_SHA1) == OK); + result = ctx.finish(); + REQUIRE(result.size() == 20); + CHECK(memcmp(result.ptr(), sha1_expected, 20) == 0); + + CHECK(ctx.start(HashingContext::HASH_SHA256) == OK); + result = ctx.finish(); + REQUIRE(result.size() == 32); + CHECK(memcmp(result.ptr(), sha256_expected, 32) == 0); +} + +TEST_CASE("[HashingContext] Multiple updates - MD5/SHA1/SHA256") { + HashingContext ctx; + const String s = "xyz"; + + const PackedByteArray s_byte_parts[] = { + String("x").to_ascii_buffer(), + String("y").to_ascii_buffer(), + String("z").to_ascii_buffer() + }; + + static const uint8_t md5_expected[] = { + 0xd1, 0x6f, 0xb3, 0x6f, 0x09, 0x11, 0xf8, 0x78, 0x99, 0x8c, 0x13, 0x61, 0x91, 0xaf, 0x70, 0x5e + }; + static const uint8_t sha1_expected[] = { + 0x66, 0xb2, 0x74, 0x17, 0xd3, 0x7e, 0x02, 0x4c, 0x46, 0x52, 0x6c, 0x2f, 0x6d, 0x35, 0x8a, 0x75, + 0x4f, 0xc5, 0x52, 0xf3 + }; + static const uint8_t sha256_expected[] = { + 0x36, 0x08, 0xbc, 0xa1, 0xe4, 0x4e, 0xa6, 0xc4, 0xd2, 0x68, 0xeb, 0x6d, 0xb0, 0x22, 0x60, 0x26, + 0x98, 0x92, 0xc0, 0xb4, 0x2b, 0x86, 0xbb, 0xf1, 0xe7, 0x7a, 0x6f, 0xa1, 0x6c, 0x3c, 0x92, 0x82 + }; + + CHECK(ctx.start(HashingContext::HASH_MD5) == OK); + CHECK(ctx.update(s_byte_parts[0]) == OK); + CHECK(ctx.update(s_byte_parts[1]) == OK); + CHECK(ctx.update(s_byte_parts[2]) == OK); + PackedByteArray result = ctx.finish(); + REQUIRE(result.size() == 16); + CHECK(memcmp(result.ptr(), md5_expected, 16) == 0); + + CHECK(ctx.start(HashingContext::HASH_SHA1) == OK); + CHECK(ctx.update(s_byte_parts[0]) == OK); + CHECK(ctx.update(s_byte_parts[1]) == OK); + CHECK(ctx.update(s_byte_parts[2]) == OK); + result = ctx.finish(); + REQUIRE(result.size() == 20); + CHECK(memcmp(result.ptr(), sha1_expected, 20) == 0); + + CHECK(ctx.start(HashingContext::HASH_SHA256) == OK); + CHECK(ctx.update(s_byte_parts[0]) == OK); + CHECK(ctx.update(s_byte_parts[1]) == OK); + CHECK(ctx.update(s_byte_parts[2]) == OK); + result = ctx.finish(); + REQUIRE(result.size() == 32); + CHECK(memcmp(result.ptr(), sha256_expected, 32) == 0); +} + +TEST_CASE("[HashingContext] Invalid use of start") { + HashingContext ctx; + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.start(static_cast<HashingContext::HashType>(-1)) == ERR_UNAVAILABLE, + "Using invalid hash types should fail."); + ERR_PRINT_ON; + + REQUIRE(ctx.start(HashingContext::HASH_MD5) == OK); + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.start(HashingContext::HASH_MD5) == ERR_ALREADY_IN_USE, + "Calling 'start' twice before 'finish' should fail."); + ERR_PRINT_ON; +} + +TEST_CASE("[HashingContext] Invalid use of update") { + HashingContext ctx; + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.update(PackedByteArray()) == ERR_UNCONFIGURED, + "Calling 'update' before 'start' should fail."); + ERR_PRINT_ON; + + REQUIRE(ctx.start(HashingContext::HASH_MD5) == OK); + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.update(PackedByteArray()) == FAILED, + "Calling 'update' with an empty byte array should fail."); + ERR_PRINT_ON; +} + +TEST_CASE("[HashingContext] Invalid use of finish") { + HashingContext ctx; + + ERR_PRINT_OFF; + CHECK_MESSAGE( + ctx.finish() == PackedByteArray(), + "Calling 'finish' before 'start' should return an empty byte array."); + ERR_PRINT_ON; +} +} // namespace TestHashingContext + +#endif // TEST_HASHING_CONTEXT_H diff --git a/tests/test_list.h b/tests/test_list.h index 1c70b6e961..52d5edff70 100644 --- a/tests/test_list.h +++ b/tests/test_list.h @@ -260,7 +260,7 @@ TEST_CASE("[List] Invert") { List<int>::Element *n[4]; populate_integers(list, n, 4); - list.invert(); + list.reverse(); CHECK(list.front()->get() == 3); CHECK(list.front()->next()->get() == 2); diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 7e9f8319a0..d06d604532 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -42,12 +42,14 @@ #include "test_config_file.h" #include "test_crypto.h" #include "test_curve.h" +#include "test_dictionary.h" #include "test_expression.h" #include "test_file_access.h" #include "test_geometry_2d.h" #include "test_geometry_3d.h" #include "test_gradient.h" #include "test_gui.h" +#include "test_hashing_context.h" #include "test_image.h" #include "test_json.h" #include "test_list.h" @@ -61,6 +63,7 @@ #include "test_object.h" #include "test_ordered_hash_map.h" #include "test_paged_array.h" +#include "test_path_3d.h" #include "test_pck_packer.h" #include "test_physics_2d.h" #include "test_physics_3d.h" diff --git a/tests/test_path_3d.h b/tests/test_path_3d.h new file mode 100644 index 0000000000..9961ae6e97 --- /dev/null +++ b/tests/test_path_3d.h @@ -0,0 +1,85 @@ +/*************************************************************************/ +/* test_path_3d.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef TEST_PATH_3D_H +#define TEST_PATH_3D_H + +#include "scene/3d/path_3d.h" +#include "scene/resources/curve.h" + +#include "tests/test_macros.h" + +namespace TestPath3D { + +TEST_CASE("[Path3D] Initialization") { + SUBCASE("Path should be empty right after initialization") { + Path3D *test_path = memnew(Path3D); + CHECK(test_path->get_curve() == nullptr); + memdelete(test_path); + } +} + +TEST_CASE("[Path3D] Curve setter and getter") { + SUBCASE("Curve passed to the class should remain the same") { + Path3D *test_path = memnew(Path3D); + const Ref<Curve3D> &curve = memnew(Curve3D); + + test_path->set_curve(curve); + CHECK(test_path->get_curve() == curve); + memdelete(test_path); + } + SUBCASE("Curve passed many times to the class should remain the same") { + Path3D *test_path = memnew(Path3D); + const Ref<Curve3D> &curve = memnew(Curve3D); + + test_path->set_curve(curve); + test_path->set_curve(curve); + test_path->set_curve(curve); + CHECK(test_path->get_curve() == curve); + memdelete(test_path); + } + SUBCASE("Curve rewrite testing") { + Path3D *test_path = memnew(Path3D); + const Ref<Curve3D> &curve1 = memnew(Curve3D); + const Ref<Curve3D> &curve2 = memnew(Curve3D); + + test_path->set_curve(curve1); + test_path->set_curve(curve2); + CHECK_MESSAGE(test_path->get_curve() != curve1, + "After rewrite, second curve should be in class"); + CHECK_MESSAGE(test_path->get_curve() == curve2, + "After rewrite, second curve should be in class"); + memdelete(test_path); + } +} + +} // namespace TestPath3D + +#endif // TEST_PATH_3D diff --git a/tests/test_physics_2d.cpp b/tests/test_physics_2d.cpp index 570e1897d6..25b2871890 100644 --- a/tests/test_physics_2d.cpp +++ b/tests/test_physics_2d.cpp @@ -216,10 +216,10 @@ protected: if (mm.is_valid()) { Point2 p = mm->get_position(); - if (mm->get_button_mask() & BUTTON_MASK_LEFT) { + if (mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) { ray_to = p; _do_ray_query(); - } else if (mm->get_button_mask() & BUTTON_MASK_RIGHT) { + } else if (mm->get_button_mask() & MOUSE_BUTTON_MASK_RIGHT) { ray_from = p; _do_ray_query(); } @@ -243,9 +243,7 @@ protected: Size2 imgsize(5, 5); //vs->texture_get_width(body_shape_data[p_shape].image), vs->texture_get_height(body_shape_data[p_shape].image)); vs->canvas_item_add_texture_rect(sprite, Rect2(-imgsize / 2.0, imgsize), body_shape_data[p_shape].image); - ps->body_set_force_integration_callback(body, this, "_body_moved", sprite); - //RID q = ps->query_create(this,"_body_moved",sprite); - //ps->query_body_state(q,body); + ps->body_set_force_integration_callback(body, callable_mp(this, &TestPhysics2DMainLoop::_body_moved), sprite); return body; } @@ -310,7 +308,6 @@ protected: } static void _bind_methods() { - ClassDB::bind_method(D_METHOD("_body_moved"), &TestPhysics2DMainLoop::_body_moved); ClassDB::bind_method(D_METHOD("_ray_query_callback"), &TestPhysics2DMainLoop::_ray_query_callback); } diff --git a/tests/test_physics_3d.cpp b/tests/test_physics_3d.cpp index 74afbad9d1..ac8078a0a8 100644 --- a/tests/test_physics_3d.cpp +++ b/tests/test_physics_3d.cpp @@ -77,10 +77,6 @@ class TestPhysics3DMainLoop : public MainLoop { bool quit; protected: - static void _bind_methods() { - ClassDB::bind_method("body_changed_transform", &TestPhysics3DMainLoop::body_changed_transform); - } - RID create_body(PhysicsServer3D::ShapeType p_shape, PhysicsServer3D::BodyMode p_body, const Transform p_location, bool p_active_default = true, const Transform &p_shape_xform = Transform()) { RenderingServer *vs = RenderingServer::get_singleton(); PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); @@ -93,7 +89,7 @@ protected: ps->body_set_param(body, PhysicsServer3D::BODY_PARAM_BOUNCE, 0.0); //todo set space 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_force_integration_callback(body, callable_mp(this, &TestPhysics3DMainLoop::body_changed_transform), mesh_instance); ps->body_set_state(body, PhysicsServer3D::BODY_STATE_TRANSFORM, p_location); bodies.push_back(body); @@ -187,8 +183,10 @@ protected: RenderingServer *vs = RenderingServer::get_singleton(); PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); RID trimesh_shape = ps->shape_create(PhysicsServer3D::SHAPE_CONCAVE_POLYGON); - ps->shape_set_data(trimesh_shape, p_faces); - p_faces = ps->shape_get_data(trimesh_shape); // optimized one + Dictionary trimesh_params; + trimesh_params["faces"] = p_faces; + trimesh_params["backface_collision"] = false; + ps->shape_set_data(trimesh_shape, trimesh_params); Vector<Vector3> normals; // for drawing for (int i = 0; i < p_faces.size() / 3; i++) { Plane p(p_faces[i * 3 + 0], p_faces[i * 3 + 1], p_faces[i * 3 + 2]); @@ -368,8 +366,7 @@ public: ps->body_set_space(character, space); //todo add space ps->body_add_shape(character, capsule_shape); - - ps->body_set_force_integration_callback(character, this, "body_changed_transform", mesh_instance); + ps->body_set_force_integration_callback(character, callable_mp(this, &TestPhysics3DMainLoop::body_changed_transform), mesh_instance); ps->body_set_state(character, PhysicsServer3D::BODY_STATE_TRANSFORM, Transform(Basis(), Vector3(-2, 5, -2))); bodies.push_back(character); diff --git a/tests/test_shader_lang.cpp b/tests/test_shader_lang.cpp index a023f35506..2169350c02 100644 --- a/tests/test_shader_lang.cpp +++ b/tests/test_shader_lang.cpp @@ -344,7 +344,7 @@ MainLoop *test() { Set<String> types; types.insert("spatial"); - Error err = sl.compile(code, dt, rm, types, nullptr); + Error err = sl.compile(code, dt, rm, ShaderLanguage::VaryingFunctionNames(), types, nullptr); if (err) { print_line("Error at line: " + rtos(sl.get_error_line()) + ": " + sl.get_error_text()); diff --git a/tests/test_string.h b/tests/test_string.h index 17f24fb0d8..486c17dbbd 100644 --- a/tests/test_string.h +++ b/tests/test_string.h @@ -860,10 +860,10 @@ TEST_CASE("[String] match") { } TEST_CASE("[String] IPVX address to string") { - IP_Address ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); - IP_Address ip(0x0123, 0x4567, 0x89ab, 0xcdef, true); - IP_Address ip2("fe80::52e5:49ff:fe93:1baf"); - IP_Address ip3("::ffff:192.168.0.1"); + IPAddress ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); + IPAddress ip(0x0123, 0x4567, 0x89ab, 0xcdef, true); + IPAddress ip2("fe80::52e5:49ff:fe93:1baf"); + IPAddress ip3("::ffff:192.168.0.1"); String ip4 = "192.168.0.1"; CHECK(ip4.is_valid_ip_address()); @@ -1045,7 +1045,7 @@ TEST_CASE("[String] lstrip and rstrip") { TEST_CASE("[String] ensuring empty string into parse_utf8 passes empty string") { String empty; - CHECK(empty.parse_utf8(NULL, -1)); + CHECK(empty.parse_utf8(nullptr, -1)); } TEST_CASE("[String] Cyrillic to_lower()") { @@ -1156,6 +1156,17 @@ TEST_CASE("[String] uri_encode/unescape") { String s = "Godot Engine:'docs'"; String t = "Godot%20Engine%3A%27docs%27"; + String x1 = "T%C4%93%C5%A1t"; + static const uint8_t u8str[] = { 0x54, 0xC4, 0x93, 0xC5, 0xA1, 0x74, 0x00 }; + String x2 = String::utf8((const char *)u8str); + String x3 = U"Tēšt"; + + CHECK(x1.uri_decode() == x2); + CHECK(x1.uri_decode() == x3); + CHECK((x1 + x3).uri_decode() == (x2 + x3)); // Mixed unicode and URL encoded string, e.g. GTK+ bookmark. + CHECK(x2.uri_encode() == x1); + CHECK(x3.uri_encode() == x1); + CHECK(s.uri_encode() == t); CHECK(t.uri_decode() == s); } @@ -1318,6 +1329,20 @@ TEST_CASE("[String] humanize_size") { CHECK(String::humanize_size(100523550) == "95.86 MiB"); CHECK(String::humanize_size(5345555000) == "4.97 GiB"); } + +TEST_CASE("[String] validate_node_name") { + String numeric_only = "12345"; + CHECK(numeric_only.validate_node_name() == "12345"); + + String name_with_spaces = "Name with spaces"; + CHECK(name_with_spaces.validate_node_name() == "Name with spaces"); + + String name_with_kana = "Name with kana ゴドツ"; + CHECK(name_with_kana.validate_node_name() == "Name with kana ゴドツ"); + + String name_with_invalid_chars = "Name with invalid characters :.@removed!"; + CHECK(name_with_invalid_chars.validate_node_name() == "Name with invalid characters removed!"); +} } // namespace TestString #endif // TEST_STRING_H diff --git a/tests/test_text_server.h b/tests/test_text_server.h index b0b40447fe..3d700f8ec4 100644 --- a/tests/test_text_server.h +++ b/tests/test_text_server.h @@ -28,6 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#ifdef TOOLS_ENABLED + #ifndef TEST_TEXT_SERVER_H #define TEST_TEXT_SERVER_H @@ -247,3 +249,4 @@ TEST_SUITE("[[TextServer]") { }; // namespace TestTextServer #endif // TEST_TEXT_SERVER_H +#endif // TOOLS_ENABLED |