summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/SCsub5
-rw-r--r--tests/test_aabb.h4
-rw-r--r--tests/test_astar.h4
-rw-r--r--tests/test_basis.h4
-rw-r--r--tests/test_class_db.h74
-rw-r--r--tests/test_color.h4
-rw-r--r--tests/test_command_queue.h4
-rw-r--r--tests/test_config_file.h4
-rw-r--r--tests/test_crypto.h4
-rw-r--r--tests/test_curve.h4
-rw-r--r--tests/test_expression.h8
-rw-r--r--tests/test_file_access.h7
-rw-r--r--tests/test_geometry_2d.h553
-rw-r--r--tests/test_gradient.h4
-rw-r--r--tests/test_gui.cpp8
-rw-r--r--tests/test_gui.h4
-rw-r--r--tests/test_json.h4
-rw-r--r--tests/test_list.h14
-rw-r--r--tests/test_local_vector.h229
-rw-r--r--tests/test_lru.h4
-rw-r--r--tests/test_macros.cpp4
-rw-r--r--tests/test_macros.h10
-rw-r--r--tests/test_main.cpp7
-rw-r--r--tests/test_main.h4
-rw-r--r--tests/test_marshalls.h329
-rw-r--r--tests/test_math.cpp8
-rw-r--r--tests/test_math.h4
-rw-r--r--tests/test_method_bind.h4
-rw-r--r--tests/test_node_path.h4
-rw-r--r--tests/test_oa_hash_map.cpp4
-rw-r--r--tests/test_oa_hash_map.h4
-rw-r--r--tests/test_object.h4
-rw-r--r--tests/test_ordered_hash_map.h4
-rw-r--r--tests/test_paged_array.h4
-rw-r--r--tests/test_pck_packer.h4
-rw-r--r--tests/test_physics_2d.cpp10
-rw-r--r--tests/test_physics_2d.h4
-rw-r--r--tests/test_physics_3d.cpp16
-rw-r--r--tests/test_physics_3d.h4
-rw-r--r--tests/test_random_number_generator.h32
-rw-r--r--tests/test_rect2.h20
-rw-r--r--tests/test_render.cpp4
-rw-r--r--tests/test_render.h4
-rw-r--r--tests/test_shader_lang.cpp6
-rw-r--r--tests/test_shader_lang.h4
-rw-r--r--tests/test_string.h12
-rw-r--r--tests/test_text_server.h6
-rw-r--r--tests/test_utils.cpp42
-rw-r--r--tests/test_utils.h42
-rw-r--r--tests/test_validate_testing.h10
-rw-r--r--tests/test_variant.h4
51 files changed, 1383 insertions, 181 deletions
diff --git a/tests/SCsub b/tests/SCsub
index 7aab28531d..0f3c14f0bd 100644
--- a/tests/SCsub
+++ b/tests/SCsub
@@ -17,6 +17,11 @@ if env["module_gdnative_enabled"]:
if env_tests["platform"] == "windows":
env_tests.Append(CPPDEFINES=[("DOCTEST_THREAD_LOCAL", "")])
+# Increase number of addressable sections in object files
+# due to doctest's heavy use of templates and macros.
+if env_tests.msvc:
+ env_tests.Append(CCFLAGS=["/bigobj"])
+
env_tests.add_source_files(env.tests_sources, "*.cpp")
lib = env_tests.add_library("tests", env.tests_sources)
diff --git a/tests/test_aabb.h b/tests/test_aabb.h
index 404a73a95f..517c4dcefd 100644
--- a/tests/test_aabb.h
+++ b/tests/test_aabb.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_astar.h b/tests/test_astar.h
index cd1bd84c15..12664a5ff1 100644
--- a/tests/test_astar.h
+++ b/tests/test_astar.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_basis.h b/tests/test_basis.h
index 00a00b4a5b..11c68f9eb7 100644
--- a/tests/test_basis.h
+++ b/tests/test_basis.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_class_db.h b/tests/test_class_db.h
index 9a30891c16..b1440b83ef 100644
--- a/tests/test_class_db.h
+++ b/tests/test_class_db.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GODOT_TEST_CLASS_DB_H
-#define GODOT_TEST_CLASS_DB_H
+#ifndef TEST_CLASS_DB_H
+#define TEST_CLASS_DB_H
#include "core/register_core_types.h"
@@ -42,11 +42,6 @@
#include "tests/test_macros.h"
-#define TEST_COND DOCTEST_CHECK_FALSE_MESSAGE
-#define TEST_FAIL DOCTEST_FAIL
-#define TEST_FAIL_COND DOCTEST_REQUIRE_FALSE_MESSAGE
-#define TEST_FAIL_COND_WARN DOCTEST_WARN_FALSE_MESSAGE
-
namespace TestClassDB {
struct TypeReference {
@@ -298,7 +293,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
const ExposedClass *top = &p_class;
while (!setter && top->base != StringName()) {
top = p_context.find_exposed_class(top->base);
- TEST_FAIL_COND(!top, "Class not found '" + top->base + "'. Inherited by '" + top->name + "'.");
+ TEST_FAIL_COND(!top, "Class not found '", top->base, "'. Inherited by '", top->name, "'.");
setter = top->find_method_by_name(p_prop.setter);
}
@@ -308,23 +303,23 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
top = &p_class;
while (!getter && top->base != StringName()) {
top = p_context.find_exposed_class(top->base);
- TEST_FAIL_COND(!top, "Class not found '" + top->base + "'. Inherited by '" + top->name + "'.");
+ TEST_FAIL_COND(!top, "Class not found '", top->base, "'. Inherited by '", top->name, "'.");
getter = top->find_method_by_name(p_prop.getter);
}
TEST_FAIL_COND((!setter && !getter),
- "Couldn't find neither the setter nor the getter for property: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ "Couldn't find neither the setter nor the getter for property: '", p_class.name, ".", String(p_prop.name), "'.");
if (setter) {
int setter_argc = p_prop.index != -1 ? 2 : 1;
TEST_FAIL_COND(setter->arguments.size() != setter_argc,
- "Invalid property setter argument count: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ "Invalid property setter argument count: '", p_class.name, ".", String(p_prop.name), "'.");
}
if (getter) {
int getter_argc = p_prop.index != -1 ? 1 : 0;
TEST_FAIL_COND(getter->arguments.size() != getter_argc,
- "Invalid property setter argument count: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ "Invalid property setter argument count: '", p_class.name, ".", String(p_prop.name), "'.");
}
if (getter && setter) {
@@ -335,7 +330,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
setter_first_arg.type.name == p_context.names_cache.string_type;
TEST_FAIL_COND(!whitelisted,
- "Return type from getter doesn't match first argument of setter, for property: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ "Return type from getter doesn't match first argument of setter, for property: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
@@ -344,10 +339,10 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
const ExposedClass *prop_class = p_context.find_exposed_class(prop_type_ref);
if (prop_class) {
TEST_COND(prop_class->is_singleton,
- "Property type is a singleton: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ "Property type is a singleton: '", p_class.name, ".", String(p_prop.name), "'.");
} else {
TEST_FAIL_COND(!p_context.has_type(prop_type_ref),
- "Property type '" + prop_type_ref.name + "' not found: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ "Property type '", prop_type_ref.name, "' not found: '", p_class.name, ".", String(p_prop.name), "'.");
}
if (getter) {
@@ -356,7 +351,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
if (idx_arg.type.name != p_context.names_cache.int_type) {
// If not an int, it can be an enum
TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
- "Invalid type '" + idx_arg.type.name + "' for index argument of property getter: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ "Invalid type '", idx_arg.type.name, "' for index argument of property getter: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
}
@@ -368,7 +363,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
// Assume the index parameter is an enum
// If not an int, it can be an enum
TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
- "Invalid type '" + idx_arg.type.name + "' for index argument of property setter: '" + p_class.name + "." + String(p_prop.name) + "'.");
+ "Invalid type '", idx_arg.type.name, "' for index argument of property setter: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
}
@@ -378,7 +373,7 @@ void validate_method(const Context &p_context, const ExposedClass &p_class, cons
const ExposedClass *return_class = p_context.find_exposed_class(p_method.return_type);
if (return_class) {
TEST_COND(return_class->is_singleton,
- "Method return type is a singleton: '" + p_class.name + "." + p_method.name + "'.");
+ "Method return type is a singleton: '", p_class.name, ".", p_method.name, "'.");
}
for (const List<ArgumentData>::Element *F = p_method.arguments.front(); F; F = F->next()) {
@@ -387,17 +382,17 @@ void validate_method(const Context &p_context, const ExposedClass &p_class, cons
const ExposedClass *arg_class = p_context.find_exposed_class(arg.type);
if (arg_class) {
TEST_COND(arg_class->is_singleton,
- "Argument type is a singleton: '" + arg.name + "' of method '" + p_class.name + "." + p_method.name + "'.");
+ "Argument type is a singleton: '", arg.name, "' of method '", p_class.name, ".", p_method.name, "'.");
} else {
TEST_FAIL_COND(!p_context.has_type(arg.type),
- "Argument type '" + arg.type.name + "' not found: '" + arg.name + "' of method" + p_class.name + "." + p_method.name + "'.");
+ "Argument type '", arg.type.name, "' not found: '", arg.name, "' of method", p_class.name, ".", p_method.name, "'.");
}
if (arg.has_defval) {
String type_error_msg;
bool arg_defval_assignable_to_type = arg_default_value_is_assignable_to_type(p_context, arg.defval, arg.type, &type_error_msg);
String err_msg = vformat("Invalid default value for parameter '%s' of method '%s.%s'.", arg.name, p_class.name, p_method.name);
- if (!type_error_msg.empty()) {
+ if (!type_error_msg.is_empty()) {
err_msg += " " + type_error_msg;
}
TEST_COND(!arg_defval_assignable_to_type, err_msg.utf8().get_data());
@@ -412,10 +407,10 @@ void validate_signal(const Context &p_context, const ExposedClass &p_class, cons
const ExposedClass *arg_class = p_context.find_exposed_class(arg.type);
if (arg_class) {
TEST_COND(arg_class->is_singleton,
- "Argument class is a singleton: '" + arg.name + "' of signal" + p_class.name + "." + p_signal.name + "'.");
+ "Argument class is a singleton: '", arg.name, "' of signal", p_class.name, ".", p_signal.name, "'.");
} else {
TEST_FAIL_COND(!p_context.has_type(arg.type),
- "Argument type '" + arg.type.name + "' not found: '" + arg.name + "' of signal" + p_class.name + "." + p_signal.name + "'.");
+ "Argument type '", arg.type.name, "' not found: '", arg.name, "' of signal", p_class.name, ".", p_signal.name, "'.");
}
}
}
@@ -426,7 +421,7 @@ void validate_class(const Context &p_context, const ExposedClass &p_exposed_clas
if (!is_derived_type) {
// Asserts about the base Object class
TEST_FAIL_COND(p_exposed_class.name != p_context.names_cache.object_class,
- "Class '" + p_exposed_class.name + "' has no base class.");
+ "Class '", p_exposed_class.name, "' has no base class.");
TEST_FAIL_COND(!p_exposed_class.is_instantiable,
"Object class is not instantiable.");
TEST_FAIL_COND(p_exposed_class.api_type != ClassDB::API_CORE,
@@ -436,10 +431,10 @@ void validate_class(const Context &p_context, const ExposedClass &p_exposed_clas
}
TEST_FAIL_COND((p_exposed_class.is_singleton && p_exposed_class.base != p_context.names_cache.object_class),
- "Singleton base class '" + String(p_exposed_class.base) + "' is not Object, for class '" + p_exposed_class.name + "'.");
+ "Singleton base class '", String(p_exposed_class.base), "' is not Object, for class '", p_exposed_class.name, "'.");
TEST_FAIL_COND((is_derived_type && !p_context.exposed_classes.has(p_exposed_class.base)),
- "Base type '" + p_exposed_class.base.operator String() + "' does not exist, for class '" + p_exposed_class.name + "'.");
+ "Base type '", p_exposed_class.base.operator String(), "' does not exist, for class '", p_exposed_class.name, "'.");
for (const List<PropertyData>::Element *F = p_exposed_class.properties.front(); F; F = F->next()) {
validate_property(p_context, p_exposed_class, F->get());
@@ -519,7 +514,7 @@ void add_exposed_classes(Context &r_context) {
bool valid = false;
prop.index = ClassDB::get_property_index(class_name, prop.name, &valid);
- TEST_FAIL_COND(!valid, "Invalid property: '" + exposed_class.name + "." + String(prop.name) + "'.");
+ TEST_FAIL_COND(!valid, "Invalid property: '", exposed_class.name, ".", String(prop.name), "'.");
exposed_class.properties.push_back(prop);
}
@@ -538,7 +533,7 @@ void add_exposed_classes(Context &r_context) {
int argc = method_info.arguments.size();
- if (method_info.name.empty()) {
+ if (method_info.name.is_empty()) {
continue;
}
@@ -557,7 +552,7 @@ void add_exposed_classes(Context &r_context) {
if (!m && !method.is_virtual) {
TEST_FAIL_COND(!virtual_method_list.find(method_info),
- "Missing MethodBind for non-virtual method: '" + exposed_class.name + "." + method.name + "'.");
+ "Missing MethodBind for non-virtual method: '", exposed_class.name, ".", method.name, "'.");
// A virtual method without the virtual flag. This is a special case.
@@ -584,9 +579,8 @@ void add_exposed_classes(Context &r_context) {
bool bad_reference_hint = !method.is_virtual && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE &&
ClassDB::is_parent_class(return_info.class_name, r_context.names_cache.reference_class);
- TEST_COND(bad_reference_hint, String() + "Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'." +
- " Are you returning a reference type by pointer? Method: '" +
- exposed_class.name + "." + method.name + "'.");
+ TEST_COND(bad_reference_hint, "Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'.", " Are you returning a reference type by pointer? Method: '",
+ exposed_class.name, ".", method.name, "'.");
} else if (return_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
method.return_type.name = return_info.hint_string;
} else if (return_info.type == Variant::NIL && return_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
@@ -636,7 +630,7 @@ void add_exposed_classes(Context &r_context) {
}
TEST_COND(exposed_class.find_property_by_name(method.name),
- "Method name conflicts with property: '" + String(class_name) + "." + String(method.name) + "'.");
+ "Method name conflicts with property: '", String(class_name), ".", String(method.name), "'.");
// Classes starting with an underscore are ignored unless they're used as a property setter or getter
if (!method.is_virtual && String(method.name)[0] == '_') {
@@ -724,8 +718,8 @@ void add_exposed_classes(Context &r_context) {
for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) {
const StringName &constant_name = E->get();
int *value = class_info->constant_map.getptr(constant_name);
- TEST_FAIL_COND(!value, "Missing enum constant value: '" +
- String(class_name) + "." + String(enum_.name) + "." + String(constant_name) + "'.");
+ TEST_FAIL_COND(!value, "Missing enum constant value: '",
+ String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
constants.erase(constant_name);
ConstantData constant;
@@ -743,7 +737,7 @@ void add_exposed_classes(Context &r_context) {
for (const List<String>::Element *E = constants.front(); E; E = E->next()) {
const String &constant_name = E->get();
int *value = class_info->constant_map.getptr(StringName(E->get()));
- TEST_FAIL_COND(!value, "Missing enum constant value: '" + String(class_name) + "." + String(constant_name) + "'.");
+ TEST_FAIL_COND(!value, "Missing enum constant value: '", String(class_name), ".", String(constant_name), "'.");
ConstantData constant;
constant.name = constant_name;
@@ -822,7 +816,7 @@ TEST_SUITE("[ClassDB]") {
const ExposedClass *object_class = context.find_exposed_class(context.names_cache.object_class);
TEST_FAIL_COND(!object_class, "Object class not found.");
TEST_FAIL_COND(object_class->base != StringName(),
- "Object class derives from another class: '" + object_class->base + "'.");
+ "Object class derives from another class: '", object_class->base, "'.");
for (ExposedClasses::Element E = context.exposed_classes.front(); E; E = E.next()) {
validate_class(context, E.value());
@@ -832,4 +826,4 @@ TEST_SUITE("[ClassDB]") {
}
} // namespace TestClassDB
-#endif //GODOT_TEST_CLASS_DB_H
+#endif // TEST_CLASS_DB_H
diff --git a/tests/test_color.h b/tests/test_color.h
index c2bb63b7d0..eb8d7dcbd4 100644
--- a/tests/test_color.h
+++ b/tests/test_color.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_command_queue.h b/tests/test_command_queue.h
index ce42d94475..2f0b75760d 100644
--- a/tests/test_command_queue.h
+++ b/tests/test_command_queue.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_config_file.h b/tests/test_config_file.h
index f910ca4b1f..958341018b 100644
--- a/tests/test_config_file.h
+++ b/tests/test_config_file.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_crypto.h b/tests/test_crypto.h
index 9e219ceec9..8da8c75544 100644
--- a/tests/test_crypto.h
+++ b/tests/test_crypto.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_curve.h b/tests/test_curve.h
index b123ef6325..019941a7ce 100644
--- a/tests/test_curve.h
+++ b/tests/test_curve.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_expression.h b/tests/test_expression.h
index 0d970ba87a..0ef60d1a19 100644
--- a/tests/test_expression.h
+++ b/tests/test_expression.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -173,11 +173,11 @@ TEST_CASE("[Expression] Built-in functions") {
"`sqrt(pow(3, 2) + pow(4, 2))` should return the expected result.");
CHECK_MESSAGE(
- expression.parse("stepify(sin(0.5), 0.01)") == OK,
+ expression.parse("snapped(sin(0.5), 0.01)") == OK,
"The expression should parse successfully.");
CHECK_MESSAGE(
Math::is_equal_approx(float(expression.execute()), 0.48),
- "`stepify(sin(0.5), 0.01)` should return the expected result.");
+ "`snapped(sin(0.5), 0.01)` should return the expected result.");
CHECK_MESSAGE(
expression.parse("pow(2.0, -2500)") == OK,
diff --git a/tests/test_file_access.h b/tests/test_file_access.h
index 0d5c9d79ce..00a314644c 100644
--- a/tests/test_file_access.h
+++ b/tests/test_file_access.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -32,11 +32,12 @@
#define TEST_FILE_ACCESS_H
#include "core/os/file_access.h"
+#include "test_utils.h"
namespace TestFileAccess {
TEST_CASE("[FileAccess] CSV read") {
- FileAccess *f = FileAccess::open("tests/data/translations.csv", FileAccess::READ);
+ FileAccess *f = FileAccess::open(TestUtils::get_data_path("translations.csv"), FileAccess::READ);
Vector<String> header = f->get_csv_line(); // Default delimiter: ","
REQUIRE(header.size() == 3);
diff --git a/tests/test_geometry_2d.h b/tests/test_geometry_2d.h
new file mode 100644
index 0000000000..ea02d1114f
--- /dev/null
+++ b/tests/test_geometry_2d.h
@@ -0,0 +1,553 @@
+/*************************************************************************/
+/* test_geometry_2d.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_GEOMETRY_2D_H
+#define TEST_GEOMETRY_2D_H
+
+#include "core/math/geometry_2d.h"
+#include "core/templates/vector.h"
+
+#include "thirdparty/doctest/doctest.h"
+
+namespace TestGeometry2D {
+
+TEST_CASE("[Geometry2D] Point in circle") {
+ CHECK(Geometry2D::is_point_in_circle(Vector2(0, 0), Vector2(0, 0), 1.0));
+
+ CHECK(Geometry2D::is_point_in_circle(Vector2(0, 0), Vector2(11.99, 0), 12));
+ CHECK(Geometry2D::is_point_in_circle(Vector2(-11.99, 0), Vector2(0, 0), 12));
+
+ CHECK_FALSE(Geometry2D::is_point_in_circle(Vector2(0, 0), Vector2(12.01, 0), 12));
+ CHECK_FALSE(Geometry2D::is_point_in_circle(Vector2(-12.01, 0), Vector2(0, 0), 12));
+
+ CHECK(Geometry2D::is_point_in_circle(Vector2(7, -42), Vector2(4, -40), 3.7));
+ CHECK_FALSE(Geometry2D::is_point_in_circle(Vector2(7, -42), Vector2(4, -40), 3.5));
+
+ // This tests points on the edge of the circle. They are treated as beeing inside the circle.
+ // In `is_point_in_triangle` and `is_point_in_polygon` they are treated as being outside, so in order the make
+ // the behaviour consistent this may change in the future (see issue #44717 and PR #44274).
+ CHECK(Geometry2D::is_point_in_circle(Vector2(1.0, 0.0), Vector2(0, 0), 1.0));
+ CHECK(Geometry2D::is_point_in_circle(Vector2(0.0, -1.0), Vector2(0, 0), 1.0));
+}
+
+TEST_CASE("[Geometry2D] Point in triangle") {
+ CHECK(Geometry2D::is_point_in_triangle(Vector2(0, 0), Vector2(-1, 1), Vector2(0, -1), Vector2(1, 1)));
+ CHECK_FALSE(Geometry2D::is_point_in_triangle(Vector2(-1.01, 1.0), Vector2(-1, 1), Vector2(0, -1), Vector2(1, 1)));
+
+ CHECK(Geometry2D::is_point_in_triangle(Vector2(3, 2.5), Vector2(1, 4), Vector2(3, 2), Vector2(5, 4)));
+ CHECK(Geometry2D::is_point_in_triangle(Vector2(-3, -2.5), Vector2(-1, -4), Vector2(-3, -2), Vector2(-5, -4)));
+ CHECK_FALSE(Geometry2D::is_point_in_triangle(Vector2(0, 0), Vector2(1, 4), Vector2(3, 2), Vector2(5, 4)));
+
+ // This tests points on the edge of the triangle. They are treated as beeing outside the triangle.
+ // In `is_point_in_circle` they are treated as being inside, so in order the make
+ // the behaviour consistent this may change in the future (see issue #44717 and PR #44274).
+ CHECK_FALSE(Geometry2D::is_point_in_triangle(Vector2(1, 1), Vector2(-1, 1), Vector2(0, -1), Vector2(1, 1)));
+ CHECK_FALSE(Geometry2D::is_point_in_triangle(Vector2(0, 1), Vector2(-1, 1), Vector2(0, -1), Vector2(1, 1)));
+}
+
+TEST_CASE("[Geometry2D] Point in polygon") {
+ Vector<Vector2> p;
+ CHECK_FALSE(Geometry2D::is_point_in_polygon(Vector2(0, 0), p));
+
+ p.push_back(Vector2(-88, 120));
+ p.push_back(Vector2(-74, -38));
+ p.push_back(Vector2(135, -145));
+ p.push_back(Vector2(425, 70));
+ p.push_back(Vector2(68, 112));
+ p.push_back(Vector2(-120, 370));
+ p.push_back(Vector2(-323, -145));
+ CHECK_FALSE(Geometry2D::is_point_in_polygon(Vector2(-350, 0), p));
+ CHECK_FALSE(Geometry2D::is_point_in_polygon(Vector2(-110, 60), p));
+ CHECK_FALSE(Geometry2D::is_point_in_polygon(Vector2(412, 96), p));
+ CHECK_FALSE(Geometry2D::is_point_in_polygon(Vector2(83, 130), p));
+ CHECK_FALSE(Geometry2D::is_point_in_polygon(Vector2(-320, -153), p));
+
+ CHECK(Geometry2D::is_point_in_polygon(Vector2(0, 0), p));
+ CHECK(Geometry2D::is_point_in_polygon(Vector2(-230, 0), p));
+ CHECK(Geometry2D::is_point_in_polygon(Vector2(130, -110), p));
+ CHECK(Geometry2D::is_point_in_polygon(Vector2(370, 55), p));
+ CHECK(Geometry2D::is_point_in_polygon(Vector2(-160, 190), p));
+
+ // This tests points on the edge of the polygon. They are treated as beeing outside the polygon.
+ // In `is_point_in_circle` they are treated as being inside, so in order the make
+ // the behaviour consistent this may change in the future (see issue #44717 and PR #44274).
+ CHECK_FALSE(Geometry2D::is_point_in_polygon(Vector2(68, 112), p));
+ CHECK_FALSE(Geometry2D::is_point_in_polygon(Vector2(-88, 120), p));
+}
+
+TEST_CASE("[Geometry2D] Polygon clockwise") {
+ Vector<Vector2> p;
+ CHECK_FALSE(Geometry2D::is_polygon_clockwise(p));
+
+ p.push_back(Vector2(5, -5));
+ p.push_back(Vector2(-1, -5));
+ p.push_back(Vector2(-5, -1));
+ p.push_back(Vector2(-1, 3));
+ p.push_back(Vector2(1, 5));
+ CHECK(Geometry2D::is_polygon_clockwise(p));
+
+ p.invert();
+ CHECK_FALSE(Geometry2D::is_polygon_clockwise(p));
+}
+
+TEST_CASE("[Geometry2D] Line intersection") {
+ Vector2 r;
+ CHECK(Geometry2D::line_intersects_line(Vector2(2, 0), Vector2(0, 1), Vector2(0, 2), Vector2(1, 0), r));
+ CHECK(r.is_equal_approx(Vector2(2, 2)));
+
+ CHECK(Geometry2D::line_intersects_line(Vector2(-1, 1), Vector2(1, -1), Vector2(4, 1), Vector2(-1, -1), r));
+ CHECK(r.is_equal_approx(Vector2(1.5, -1.5)));
+
+ CHECK(Geometry2D::line_intersects_line(Vector2(-1, 0), Vector2(-1, -1), Vector2(1, 0), Vector2(1, -1), r));
+ CHECK(r.is_equal_approx(Vector2(0, 1)));
+
+ CHECK_FALSE_MESSAGE(
+ Geometry2D::line_intersects_line(Vector2(-1, 1), Vector2(1, -1), Vector2(0, 1), Vector2(1, -1), r),
+ "Parallel lines should not intersect.");
+}
+
+TEST_CASE("[Geometry2D] Segment intersection.") {
+ Vector2 r;
+
+ CHECK(Geometry2D::segment_intersects_segment(Vector2(-1, 1), Vector2(1, -1), Vector2(1, 1), Vector2(-1, -1), &r));
+ CHECK(r.is_equal_approx(Vector2(0, 0)));
+
+ CHECK_FALSE(Geometry2D::segment_intersects_segment(Vector2(-1, 1), Vector2(1, -1), Vector2(1, 1), Vector2(0.1, 0.1), &r));
+ CHECK_FALSE_MESSAGE(
+ Geometry2D::segment_intersects_segment(Vector2(-1, 1), Vector2(1, -1), Vector2(0, 1), Vector2(1, -1), &r),
+ "Parallel segments should not intersect.");
+}
+
+TEST_CASE("[Geometry2D] Closest point to segment") {
+ Vector2 s[] = { Vector2(-4, -4), Vector2(4, 4) };
+ CHECK(Geometry2D::get_closest_point_to_segment(Vector2(4.1, 4.1), s).is_equal_approx(Vector2(4, 4)));
+ CHECK(Geometry2D::get_closest_point_to_segment(Vector2(-4.1, -4.1), s).is_equal_approx(Vector2(-4, -4)));
+ CHECK(Geometry2D::get_closest_point_to_segment(Vector2(-1, 1), s).is_equal_approx(Vector2(0, 0)));
+}
+
+TEST_CASE("[Geometry2D] Closest point to uncapped segment") {
+ Vector2 s[] = { Vector2(-4, -4), Vector2(4, 4) };
+ CHECK(Geometry2D::get_closest_point_to_segment_uncapped(Vector2(-1, 1), s).is_equal_approx(Vector2(0, 0)));
+ CHECK(Geometry2D::get_closest_point_to_segment_uncapped(Vector2(-4, -6), s).is_equal_approx(Vector2(-5, -5)));
+ CHECK(Geometry2D::get_closest_point_to_segment_uncapped(Vector2(4, 6), s).is_equal_approx(Vector2(5, 5)));
+}
+
+TEST_CASE("[Geometry2D] Closest points between segments") {
+ Vector2 c1, c2;
+ Geometry2D::get_closest_points_between_segments(Vector2(2, 2), Vector2(3, 3), Vector2(4, 4), Vector2(4, 5), c1, c2);
+ CHECK(c1.is_equal_approx(Vector2(3, 3)));
+ CHECK(c2.is_equal_approx(Vector2(4, 4)));
+
+ Geometry2D::get_closest_points_between_segments(Vector2(0, 1), Vector2(-2, -1), Vector2(0, 0), Vector2(2, -2), c1, c2);
+ CHECK(c1.is_equal_approx(Vector2(-0.5, 0.5)));
+ CHECK(c2.is_equal_approx(Vector2(0, 0)));
+
+ Geometry2D::get_closest_points_between_segments(Vector2(-1, 1), Vector2(1, -1), Vector2(1, 1), Vector2(-1, -1), c1, c2);
+ CHECK(c1.is_equal_approx(Vector2(0, 0)));
+ CHECK(c2.is_equal_approx(Vector2(0, 0)));
+}
+
+TEST_CASE("[Geometry2D] Make atlas") {
+ Vector<Point2i> result;
+ Size2i size;
+
+ Vector<Size2i> r;
+ r.push_back(Size2i(2, 2));
+ Geometry2D::make_atlas(r, result, size);
+ CHECK(size == Size2i(2, 2));
+ CHECK(result.size() == r.size());
+
+ r.clear();
+ result.clear();
+ r.push_back(Size2i(1, 2));
+ r.push_back(Size2i(3, 4));
+ r.push_back(Size2i(5, 6));
+ r.push_back(Size2i(7, 8));
+ Geometry2D::make_atlas(r, result, size);
+ CHECK(result.size() == r.size());
+}
+
+TEST_CASE("[Geometry2D] Polygon intersection") {
+ Vector<Point2> a;
+ Vector<Point2> b;
+ Vector<Vector<Point2>> r;
+
+ a.push_back(Point2(30, 60));
+ a.push_back(Point2(70, 5));
+ a.push_back(Point2(200, 40));
+ a.push_back(Point2(80, 200));
+
+ SUBCASE("[Geometry2D] Both polygons are empty") {
+ r = Geometry2D::intersect_polygons(Vector<Point2>(), Vector<Point2>());
+ CHECK_MESSAGE(r.is_empty(), "Both polygons are empty. The intersection should also be empty.");
+ }
+
+ SUBCASE("[Geometry2D] One polygon is empty") {
+ r = Geometry2D::intersect_polygons(a, b);
+ REQUIRE_MESSAGE(r.is_empty(), "One polygon is empty. The intersection should also be empty.");
+ }
+
+ SUBCASE("[Geometry2D] Basic intersection") {
+ b.push_back(Point2(200, 300));
+ b.push_back(Point2(90, 200));
+ b.push_back(Point2(50, 100));
+ b.push_back(Point2(200, 90));
+ r = Geometry2D::intersect_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 1, "The polygons should intersect each other with 1 resulting intersection polygon.");
+ REQUIRE_MESSAGE(r[0].size() == 3, "The resulting intersection polygon should have 3 vertices.");
+ CHECK(r[0][0].is_equal_approx(Point2(86.52174, 191.30436)));
+ CHECK(r[0][1].is_equal_approx(Point2(50, 100)));
+ CHECK(r[0][2].is_equal_approx(Point2(160.52632, 92.63157)));
+ }
+
+ SUBCASE("[Geometry2D] Intersection with one polygon beeing completly inside the other polygon") {
+ b.push_back(Point2(80, 100));
+ b.push_back(Point2(50, 50));
+ b.push_back(Point2(150, 50));
+ r = Geometry2D::intersect_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 1, "The polygons should intersect each other with 1 resulting intersection polygon.");
+ REQUIRE_MESSAGE(r[0].size() == 3, "The resulting intersection polygon should have 3 vertices.");
+ CHECK(r[0][0].is_equal_approx(b[0]));
+ CHECK(r[0][1].is_equal_approx(b[1]));
+ CHECK(r[0][2].is_equal_approx(b[2]));
+ }
+
+ SUBCASE("[Geometry2D] No intersection with 2 non-empty polygons") {
+ b.push_back(Point2(150, 150));
+ b.push_back(Point2(250, 100));
+ b.push_back(Point2(300, 200));
+ r = Geometry2D::intersect_polygons(a, b);
+ REQUIRE_MESSAGE(r.is_empty(), "The polygons should not intersect each other.");
+ }
+
+ SUBCASE("[Geometry2D] Intersection with 2 resulting polygons") {
+ a.clear();
+ a.push_back(Point2(70, 5));
+ a.push_back(Point2(140, 7));
+ a.push_back(Point2(100, 52));
+ a.push_back(Point2(170, 50));
+ a.push_back(Point2(60, 125));
+ b.push_back(Point2(70, 105));
+ b.push_back(Point2(115, 55));
+ b.push_back(Point2(90, 15));
+ b.push_back(Point2(160, 50));
+ r = Geometry2D::intersect_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 2, "The polygons should intersect each other with 2 resulting intersection polygons.");
+ REQUIRE_MESSAGE(r[0].size() == 4, "The resulting intersection polygon should have 4 vertices.");
+ CHECK(r[0][0].is_equal_approx(Point2(70, 105)));
+ CHECK(r[0][1].is_equal_approx(Point2(115, 55)));
+ CHECK(r[0][2].is_equal_approx(Point2(112.894737, 51.63158)));
+ CHECK(r[0][3].is_equal_approx(Point2(159.509537, 50.299728)));
+
+ REQUIRE_MESSAGE(r[1].size() == 3, "The intersection polygon should have 3 vertices.");
+ CHECK(r[1][0].is_equal_approx(Point2(119.692307, 29.846149)));
+ CHECK(r[1][1].is_equal_approx(Point2(107.706421, 43.33028)));
+ CHECK(r[1][2].is_equal_approx(Point2(90, 15)));
+ }
+}
+
+TEST_CASE("[Geometry2D] Merge polygons") {
+ Vector<Point2> a;
+ Vector<Point2> b;
+ Vector<Vector<Point2>> r;
+
+ a.push_back(Point2(225, 180));
+ a.push_back(Point2(160, 230));
+ a.push_back(Point2(20, 212));
+ a.push_back(Point2(50, 115));
+
+ SUBCASE("[Geometry2D] Both polygons are empty") {
+ r = Geometry2D::merge_polygons(Vector<Point2>(), Vector<Point2>());
+ REQUIRE_MESSAGE(r.is_empty(), "Both polygons are empty. The union should also be empty.");
+ }
+
+ SUBCASE("[Geometry2D] One polygon is empty") {
+ r = Geometry2D::merge_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 1, "One polygon is non-empty. There should be 1 resulting merged polygon.");
+ REQUIRE_MESSAGE(r[0].size() == 4, "The resulting merged polygon should have 4 vertices.");
+ CHECK(r[0][0].is_equal_approx(a[0]));
+ CHECK(r[0][1].is_equal_approx(a[1]));
+ CHECK(r[0][2].is_equal_approx(a[2]));
+ CHECK(r[0][3].is_equal_approx(a[3]));
+ }
+
+ SUBCASE("[Geometry2D] Basic merge with 2 polygons") {
+ b.push_back(Point2(180, 190));
+ b.push_back(Point2(60, 140));
+ b.push_back(Point2(160, 80));
+ r = Geometry2D::merge_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 1, "The merged polygons should result in 1 polygon.");
+ REQUIRE_MESSAGE(r[0].size() == 7, "The resulting merged polygon should have 7 vertices.");
+ CHECK(r[0][0].is_equal_approx(Point2(174.791077, 161.350967)));
+ CHECK(r[0][1].is_equal_approx(Point2(225, 180)));
+ CHECK(r[0][2].is_equal_approx(Point2(160, 230)));
+ CHECK(r[0][3].is_equal_approx(Point2(20, 212)));
+ CHECK(r[0][4].is_equal_approx(Point2(50, 115)));
+ CHECK(r[0][5].is_equal_approx(Point2(81.911758, 126.852943)));
+ CHECK(r[0][6].is_equal_approx(Point2(160, 80)));
+ }
+
+ SUBCASE("[Geometry2D] Merge with 2 resulting merged polygons (outline and hole)") {
+ b.push_back(Point2(180, 190));
+ b.push_back(Point2(140, 125));
+ b.push_back(Point2(60, 140));
+ b.push_back(Point2(160, 80));
+ r = Geometry2D::merge_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 2, "The merged polygons should result in 2 polygons.");
+
+ REQUIRE_MESSAGE(!Geometry2D::is_polygon_clockwise(r[0]), "The merged polygon (outline) should be counter-clockwise.");
+ REQUIRE_MESSAGE(r[0].size() == 7, "The resulting merged polygon (outline) should have 7 vertices.");
+ CHECK(r[0][0].is_equal_approx(Point2(174.791077, 161.350967)));
+ CHECK(r[0][1].is_equal_approx(Point2(225, 180)));
+ CHECK(r[0][2].is_equal_approx(Point2(160, 230)));
+ CHECK(r[0][3].is_equal_approx(Point2(20, 212)));
+ CHECK(r[0][4].is_equal_approx(Point2(50, 115)));
+ CHECK(r[0][5].is_equal_approx(Point2(81.911758, 126.852943)));
+ CHECK(r[0][6].is_equal_approx(Point2(160, 80)));
+
+ REQUIRE_MESSAGE(Geometry2D::is_polygon_clockwise(r[1]), "The resulting merged polygon (hole) should be clockwise.");
+ REQUIRE_MESSAGE(r[1].size() == 3, "The resulting merged polygon (hole) should have 3 vertices.");
+ CHECK(r[1][0].is_equal_approx(Point2(98.083069, 132.859421)));
+ CHECK(r[1][1].is_equal_approx(Point2(158.689453, 155.370377)));
+ CHECK(r[1][2].is_equal_approx(Point2(140, 125)));
+ }
+}
+
+TEST_CASE("[Geometry2D] Clip polygons") {
+ Vector<Point2> a;
+ Vector<Point2> b;
+ Vector<Vector<Point2>> r;
+
+ a.push_back(Point2(225, 180));
+ a.push_back(Point2(160, 230));
+ a.push_back(Point2(20, 212));
+ a.push_back(Point2(50, 115));
+
+ SUBCASE("[Geometry2D] Both polygons are empty") {
+ r = Geometry2D::clip_polygons(Vector<Point2>(), Vector<Point2>());
+ CHECK_MESSAGE(r.is_empty(), "Both polygons are empty. The clip should also be empty.");
+ }
+
+ SUBCASE("[Geometry2D] Basic clip with one result polygon") {
+ b.push_back(Point2(250, 170));
+ b.push_back(Point2(175, 270));
+ b.push_back(Point2(120, 260));
+ b.push_back(Point2(25, 80));
+ r = Geometry2D::clip_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 1, "The clipped polygons should result in 1 polygon.");
+ REQUIRE_MESSAGE(r[0].size() == 3, "The resulting clipped polygon should have 3 vertices.");
+ CHECK(r[0][0].is_equal_approx(Point2(100.102173, 222.298843)));
+ CHECK(r[0][1].is_equal_approx(Point2(20, 212)));
+ CHECK(r[0][2].is_equal_approx(Point2(47.588089, 122.798492)));
+ }
+
+ SUBCASE("[Geometry2D] Polygon b completely overlaps polygon a") {
+ b.push_back(Point2(250, 170));
+ b.push_back(Point2(175, 270));
+ b.push_back(Point2(10, 210));
+ b.push_back(Point2(55, 80));
+ r = Geometry2D::clip_polygons(a, b);
+ CHECK_MESSAGE(r.is_empty(), "Polygon 'b' completely overlaps polygon 'a'. This should result in no clipped polygons.");
+ }
+
+ SUBCASE("[Geometry2D] Polygon a completely overlaps polygon b") {
+ b.push_back(Point2(150, 200));
+ b.push_back(Point2(65, 190));
+ b.push_back(Point2(80, 140));
+ r = Geometry2D::clip_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 2, "Polygon 'a' completely overlaps polygon 'b'. This should result in 2 clipped polygons.");
+ REQUIRE_MESSAGE(r[0].size() == 4, "The resulting clipped polygon should have 4 vertices.");
+ REQUIRE_MESSAGE(!Geometry2D::is_polygon_clockwise(r[0]), "The resulting clipped polygon (outline) should be counter-clockwise.");
+ CHECK(r[0][0].is_equal_approx(a[0]));
+ CHECK(r[0][1].is_equal_approx(a[1]));
+ CHECK(r[0][2].is_equal_approx(a[2]));
+ CHECK(r[0][3].is_equal_approx(a[3]));
+ REQUIRE_MESSAGE(r[1].size() == 3, "The resulting clipped polygon should have 3 vertices.");
+ REQUIRE_MESSAGE(Geometry2D::is_polygon_clockwise(r[1]), "The resulting clipped polygon (hole) should be clockwise.");
+ CHECK(r[1][0].is_equal_approx(b[1]));
+ CHECK(r[1][1].is_equal_approx(b[0]));
+ CHECK(r[1][2].is_equal_approx(b[2]));
+ }
+}
+
+TEST_CASE("[Geometry2D] Exclude polygons") {
+ Vector<Point2> a;
+ Vector<Point2> b;
+ Vector<Vector<Point2>> r;
+
+ a.push_back(Point2(225, 180));
+ a.push_back(Point2(160, 230));
+ a.push_back(Point2(20, 212));
+ a.push_back(Point2(50, 115));
+
+ SUBCASE("[Geometry2D] Both polygons are empty") {
+ r = Geometry2D::exclude_polygons(Vector<Point2>(), Vector<Point2>());
+ CHECK_MESSAGE(r.is_empty(), "Both polygons are empty. The excluded polygon should also be empty.");
+ }
+
+ SUBCASE("[Geometry2D] One polygon is empty") {
+ r = Geometry2D::exclude_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 1, "One polygon is non-empty. There should be 1 resulting excluded polygon.");
+ REQUIRE_MESSAGE(r[0].size() == 4, "The resulting excluded polygon should have 4 vertices.");
+ CHECK(r[0][0].is_equal_approx(a[0]));
+ CHECK(r[0][1].is_equal_approx(a[1]));
+ CHECK(r[0][2].is_equal_approx(a[2]));
+ CHECK(r[0][3].is_equal_approx(a[3]));
+ }
+
+ SUBCASE("[Geometry2D] Exclude with 2 resulting polygons (outline and hole)") {
+ b.push_back(Point2(140, 160));
+ b.push_back(Point2(150, 220));
+ b.push_back(Point2(40, 200));
+ b.push_back(Point2(60, 140));
+ r = Geometry2D::exclude_polygons(a, b);
+ REQUIRE_MESSAGE(r.size() == 2, "There should be 2 resulting excluded polygons (outline and hole).");
+ REQUIRE_MESSAGE(r[0].size() == 4, "The resulting excluded polygon should have 4 vertices.");
+ REQUIRE_MESSAGE(!Geometry2D::is_polygon_clockwise(r[0]), "The resulting excluded polygon (outline) should be counter-clockwise.");
+ CHECK(r[0][0].is_equal_approx(a[0]));
+ CHECK(r[0][1].is_equal_approx(a[1]));
+ CHECK(r[0][2].is_equal_approx(a[2]));
+ CHECK(r[0][3].is_equal_approx(a[3]));
+ REQUIRE_MESSAGE(r[1].size() == 4, "The resulting excluded polygon should have 4 vertices.");
+ REQUIRE_MESSAGE(Geometry2D::is_polygon_clockwise(r[1]), "The resulting excluded polygon (hole) should be clockwise.");
+ CHECK(r[1][0].is_equal_approx(Point2(40, 200)));
+ CHECK(r[1][1].is_equal_approx(Point2(150, 220)));
+ CHECK(r[1][2].is_equal_approx(Point2(140, 160)));
+ CHECK(r[1][3].is_equal_approx(Point2(60, 140)));
+ }
+}
+
+TEST_CASE("[Geometry2D] Intersect polyline with polygon") {
+ Vector<Vector2> l;
+ Vector<Vector2> p;
+ Vector<Vector<Point2>> r;
+
+ l.push_back(Vector2(100, 90));
+ l.push_back(Vector2(120, 250));
+
+ p.push_back(Vector2(225, 180));
+ p.push_back(Vector2(160, 230));
+ p.push_back(Vector2(20, 212));
+ p.push_back(Vector2(50, 115));
+
+ SUBCASE("[Geometry2D] Both line and polygon are empty") {
+ r = Geometry2D::intersect_polyline_with_polygon(Vector<Vector2>(), Vector<Vector2>());
+ CHECK_MESSAGE(r.is_empty(), "Both line and polygon are empty. The intersection line should also be empty.");
+ }
+
+ SUBCASE("[Geometry2D] Line is non-empty and polygon is empty") {
+ r = Geometry2D::intersect_polyline_with_polygon(l, Vector<Vector2>());
+ CHECK_MESSAGE(r.is_empty(), "The polygon is empty while the line is non-empty. The intersection line should be empty.");
+ }
+
+ SUBCASE("[Geometry2D] Basic intersection with 1 resulting intersection line") {
+ r = Geometry2D::intersect_polyline_with_polygon(l, p);
+ REQUIRE_MESSAGE(r.size() == 1, "There should be 1 resulting intersection line.");
+ REQUIRE_MESSAGE(r[0].size() == 2, "The resulting intersection line should have 2 vertices.");
+ CHECK(r[0][0].is_equal_approx(Vector2(105.711609, 135.692886)));
+ CHECK(r[0][1].is_equal_approx(Vector2(116.805809, 224.446457)));
+ }
+
+ SUBCASE("[Geometry2D] Complex intersection with 2 resulting intersection lines") {
+ l.clear();
+ l.push_back(Vector2(100, 90));
+ l.push_back(Vector2(190, 255));
+ l.push_back(Vector2(135, 260));
+ l.push_back(Vector2(57, 200));
+ l.push_back(Vector2(50, 170));
+ l.push_back(Vector2(15, 155));
+ r = Geometry2D::intersect_polyline_with_polygon(l, p);
+ REQUIRE_MESSAGE(r.size() == 2, "There should be 2 resulting intersection lines.");
+ REQUIRE_MESSAGE(r[0].size() == 2, "The resulting intersection line should have 2 vertices.");
+ CHECK(r[0][0].is_equal_approx(Vector2(129.804565, 144.641693)));
+ CHECK(r[0][1].is_equal_approx(Vector2(171.527084, 221.132996)));
+ REQUIRE_MESSAGE(r[1].size() == 4, "The resulting intersection line should have 4 vertices.");
+ CHECK(r[1][0].is_equal_approx(Vector2(83.15609, 220.120087)));
+ CHECK(r[1][1].is_equal_approx(Vector2(57, 200)));
+ CHECK(r[1][2].is_equal_approx(Vector2(50, 170)));
+ CHECK(r[1][3].is_equal_approx(Vector2(34.980492, 163.563065)));
+ }
+}
+
+TEST_CASE("[Geometry2D] Clip polyline with polygon") {
+ Vector<Vector2> l;
+ Vector<Vector2> p;
+ Vector<Vector<Point2>> r;
+
+ l.push_back(Vector2(70, 140));
+ l.push_back(Vector2(160, 320));
+
+ p.push_back(Vector2(225, 180));
+ p.push_back(Vector2(160, 230));
+ p.push_back(Vector2(20, 212));
+ p.push_back(Vector2(50, 115));
+
+ SUBCASE("[Geometry2D] Both line and polygon are empty") {
+ r = Geometry2D::clip_polyline_with_polygon(Vector<Vector2>(), Vector<Vector2>());
+ CHECK_MESSAGE(r.is_empty(), "Both line and polygon are empty. The clipped line should also be empty.");
+ }
+
+ SUBCASE("[Geometry2D] Polygon is empty and line is non-empty") {
+ r = Geometry2D::clip_polyline_with_polygon(l, Vector<Vector2>());
+ REQUIRE_MESSAGE(r.size() == 1, "There should be 1 resulting clipped line.");
+ REQUIRE_MESSAGE(r[0].size() == 2, "The resulting clipped line should have 2 vertices.");
+ CHECK(r[0][0].is_equal_approx(l[0]));
+ CHECK(r[0][1].is_equal_approx(l[1]));
+ }
+
+ SUBCASE("[Geometry2D] Basic clip with 1 resulting clipped line") {
+ r = Geometry2D::clip_polyline_with_polygon(l, p);
+ REQUIRE_MESSAGE(r.size() == 1, "There should be 1 resulting clipped line.");
+ REQUIRE_MESSAGE(r[0].size() == 2, "The resulting clipped line should have 2 vertices.");
+ CHECK(r[0][0].is_equal_approx(Vector2(111.908401, 223.816803)));
+ CHECK(r[0][1].is_equal_approx(Vector2(160, 320)));
+ }
+
+ SUBCASE("[Geometry2D] Complex clip with 2 resulting clipped lines") {
+ l.clear();
+ l.push_back(Vector2(55, 70));
+ l.push_back(Vector2(50, 190));
+ l.push_back(Vector2(120, 165));
+ l.push_back(Vector2(122, 250));
+ l.push_back(Vector2(160, 320));
+ r = Geometry2D::clip_polyline_with_polygon(l, p);
+ REQUIRE_MESSAGE(r.size() == 2, "There should be 2 resulting clipped lines.");
+ REQUIRE_MESSAGE(r[0].size() == 3, "The resulting clipped line should have 3 vertices.");
+ CHECK(r[0][0].is_equal_approx(Vector2(160, 320)));
+ CHECK(r[0][1].is_equal_approx(Vector2(122, 250)));
+ CHECK(r[0][2].is_equal_approx(Vector2(121.412682, 225.038757)));
+ REQUIRE_MESSAGE(r[1].size() == 2, "The resulting clipped line should have 2 vertices.");
+ CHECK(r[1][0].is_equal_approx(Vector2(53.07737, 116.143021)));
+ CHECK(r[1][1].is_equal_approx(Vector2(55, 70)));
+ }
+}
+} // namespace TestGeometry2D
+
+#endif // TEST_GEOMETRY_2D_H
diff --git a/tests/test_gradient.h b/tests/test_gradient.h
index 0c018c33e5..8eaa6b2b64 100644
--- a/tests/test_gradient.h
+++ b/tests/test_gradient.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_gui.cpp b/tests/test_gui.cpp
index a4559687c8..b83bd10af4 100644
--- a/tests/test_gui.cpp
+++ b/tests/test_gui.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -63,8 +63,8 @@ public:
virtual void request_quit() {
quit();
}
- virtual void init() {
- SceneTree::init();
+ virtual void initialize() {
+ SceneTree::initialize();
Panel *frame = memnew(Panel);
frame->set_anchor(SIDE_RIGHT, Control::ANCHOR_END);
diff --git a/tests/test_gui.h b/tests/test_gui.h
index 5a23179eee..e5c40de7e8 100644
--- a/tests/test_gui.h
+++ b/tests/test_gui.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_json.h b/tests/test_json.h
index fe29e89e06..e652a8fced 100644
--- a/tests/test_json.h
+++ b/tests/test_json.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_list.h b/tests/test_list.h
index 8d29bd907f..1c70b6e961 100644
--- a/tests/test_list.h
+++ b/tests/test_list.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -57,7 +57,7 @@ TEST_CASE("[List] Push/pop back") {
CHECK(n->get() == "C");
CHECK(list.size() == 3);
- CHECK(!list.empty());
+ CHECK(!list.is_empty());
String v;
v = list.back()->get();
@@ -71,7 +71,7 @@ TEST_CASE("[List] Push/pop back") {
CHECK(v == "A");
CHECK(list.size() == 0);
- CHECK(list.empty());
+ CHECK(list.is_empty());
CHECK(list.back() == nullptr);
CHECK(list.front() == nullptr);
@@ -89,7 +89,7 @@ TEST_CASE("[List] Push/pop front") {
CHECK(n->get() == "C");
CHECK(list.size() == 3);
- CHECK(!list.empty());
+ CHECK(!list.is_empty());
String v;
v = list.front()->get();
@@ -103,7 +103,7 @@ TEST_CASE("[List] Push/pop front") {
CHECK(v == "A");
CHECK(list.size() == 0);
- CHECK(list.empty());
+ CHECK(list.is_empty());
CHECK(list.back() == nullptr);
CHECK(list.front() == nullptr);
@@ -252,7 +252,7 @@ TEST_CASE("[List] Clear") {
list.clear();
CHECK(list.size() == 0);
- CHECK(list.empty());
+ CHECK(list.is_empty());
}
TEST_CASE("[List] Invert") {
diff --git a/tests/test_local_vector.h b/tests/test_local_vector.h
new file mode 100644
index 0000000000..eff2a16abc
--- /dev/null
+++ b/tests/test_local_vector.h
@@ -0,0 +1,229 @@
+/*************************************************************************/
+/* test_local_vector.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_LOCAL_VECTOR_H
+#define TEST_LOCAL_VECTOR_H
+
+#include "core/templates/local_vector.h"
+
+#include "tests/test_macros.h"
+
+namespace TestLocalVector {
+
+TEST_CASE("[LocalVector] Push Back.") {
+ LocalVector<int> vector;
+ vector.push_back(0);
+ vector.push_back(1);
+ vector.push_back(2);
+ vector.push_back(3);
+ vector.push_back(4);
+
+ CHECK(vector[0] == 0);
+ CHECK(vector[1] == 1);
+ CHECK(vector[2] == 2);
+ CHECK(vector[3] == 3);
+ CHECK(vector[4] == 4);
+}
+
+TEST_CASE("[LocalVector] Find.") {
+ LocalVector<int> vector;
+ vector.push_back(3);
+ vector.push_back(1);
+ vector.push_back(4);
+ vector.push_back(0);
+ vector.push_back(2);
+
+ CHECK(vector[0] == 3);
+ CHECK(vector[1] == 1);
+ CHECK(vector[2] == 4);
+ CHECK(vector[3] == 0);
+ CHECK(vector[4] == 2);
+
+ CHECK(vector.find(0) == 3);
+ CHECK(vector.find(1) == 1);
+ CHECK(vector.find(2) == 4);
+ CHECK(vector.find(3) == 0);
+ CHECK(vector.find(4) == 2);
+
+ CHECK(vector.find(-1) == -1);
+ CHECK(vector.find(5) == -1);
+}
+
+TEST_CASE("[LocalVector] Remove.") {
+ LocalVector<int> vector;
+ vector.push_back(0);
+ vector.push_back(1);
+ vector.push_back(2);
+ vector.push_back(3);
+ vector.push_back(4);
+
+ vector.remove(0);
+
+ CHECK(vector[0] == 1);
+ CHECK(vector[1] == 2);
+ CHECK(vector[2] == 3);
+ CHECK(vector[3] == 4);
+
+ vector.remove(2);
+
+ CHECK(vector[0] == 1);
+ CHECK(vector[1] == 2);
+ CHECK(vector[2] == 4);
+
+ vector.remove(1);
+
+ CHECK(vector[0] == 1);
+ CHECK(vector[1] == 4);
+
+ vector.remove(0);
+
+ CHECK(vector[0] == 4);
+}
+
+TEST_CASE("[LocalVector] Remove Unordered.") {
+ LocalVector<int> vector;
+ vector.push_back(0);
+ vector.push_back(1);
+ vector.push_back(2);
+ vector.push_back(3);
+ vector.push_back(4);
+
+ CHECK(vector.size() == 5);
+
+ vector.remove_unordered(0);
+
+ CHECK(vector.size() == 4);
+
+ CHECK(vector.find(0) == -1);
+ CHECK(vector.find(1) != -1);
+ CHECK(vector.find(2) != -1);
+ CHECK(vector.find(3) != -1);
+ CHECK(vector.find(4) != -1);
+
+ // Now the vector is no more ordered.
+ vector.remove_unordered(vector.find(3));
+
+ CHECK(vector.size() == 3);
+
+ CHECK(vector.find(3) == -1);
+ CHECK(vector.find(1) != -1);
+ CHECK(vector.find(2) != -1);
+ CHECK(vector.find(4) != -1);
+
+ vector.remove_unordered(vector.find(2));
+
+ CHECK(vector.size() == 2);
+
+ CHECK(vector.find(2) == -1);
+ CHECK(vector.find(1) != -1);
+ CHECK(vector.find(4) != -1);
+
+ vector.remove_unordered(vector.find(4));
+
+ CHECK(vector.size() == 1);
+
+ CHECK(vector.find(4) == -1);
+ CHECK(vector.find(1) != -1);
+
+ // Remove the last one.
+ vector.remove_unordered(0);
+
+ CHECK(vector.is_empty());
+ CHECK(vector.size() == 0);
+}
+
+TEST_CASE("[LocalVector] Erase.") {
+ LocalVector<int> vector;
+ vector.push_back(1);
+ vector.push_back(3);
+ vector.push_back(0);
+ vector.push_back(2);
+ vector.push_back(4);
+
+ CHECK(vector.find(2) == 3);
+
+ vector.erase(2);
+
+ CHECK(vector.find(2) == -1);
+ CHECK(vector.size() == 4);
+}
+
+TEST_CASE("[LocalVector] Size / Resize / Reserve.") {
+ LocalVector<int> vector;
+
+ CHECK(vector.is_empty());
+ CHECK(vector.size() == 0);
+ CHECK(vector.get_capacity() == 0);
+
+ vector.resize(10);
+
+ CHECK(vector.size() == 10);
+ CHECK(vector.get_capacity() >= 10);
+
+ vector.resize(5);
+
+ CHECK(vector.size() == 5);
+ // Capacity is supposed to change only when the size increase.
+ CHECK(vector.get_capacity() >= 10);
+
+ vector.remove(0);
+ vector.remove(0);
+ vector.remove(0);
+
+ CHECK(vector.size() == 2);
+ // Capacity is supposed to change only when the size increase.
+ CHECK(vector.get_capacity() >= 10);
+
+ vector.reset();
+
+ CHECK(vector.size() == 0);
+ CHECK(vector.get_capacity() == 0);
+
+ vector.reserve(3);
+
+ CHECK(vector.is_empty());
+ CHECK(vector.size() == 0);
+ CHECK(vector.get_capacity() >= 3);
+
+ vector.push_back(0);
+ vector.push_back(0);
+ vector.push_back(0);
+
+ CHECK(vector.size() == 3);
+ CHECK(vector.get_capacity() >= 3);
+
+ vector.push_back(0);
+
+ CHECK(vector.size() == 4);
+ CHECK(vector.get_capacity() >= 4);
+}
+} // namespace TestLocalVector
+
+#endif // TEST_LOCAL_VECTOR_H
diff --git a/tests/test_lru.h b/tests/test_lru.h
index 260841f4c4..2802754729 100644
--- a/tests/test_lru.h
+++ b/tests/test_lru.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_macros.cpp b/tests/test_macros.cpp
index 2317223b23..b0b28ab374 100644
--- a/tests/test_macros.cpp
+++ b/tests/test_macros.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_macros.h b/tests/test_macros.h
index ae6af93825..a13f3abbe7 100644
--- a/tests/test_macros.h
+++ b/tests/test_macros.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -44,6 +44,12 @@
// The test case is marked as failed, but does not fail the entire test run.
#define TEST_CASE_MAY_FAIL(name) TEST_CASE(name *doctest::may_fail())
+// Provide aliases to conform with Godot naming conventions (see error macros).
+#define TEST_COND(cond, ...) DOCTEST_CHECK_FALSE_MESSAGE(cond, __VA_ARGS__)
+#define TEST_FAIL(cond, ...) DOCTEST_FAIL(cond, __VA_ARGS__)
+#define TEST_FAIL_COND(cond, ...) DOCTEST_REQUIRE_FALSE_MESSAGE(cond, __VA_ARGS__)
+#define TEST_FAIL_COND_WARN(cond, ...) DOCTEST_WARN_FALSE_MESSAGE(cond, __VA_ARGS__)
+
// Temporarily disable error prints to test failure paths.
// This allows to avoid polluting the test summary with error messages.
// The `_print_error_enabled` boolean is defined in `core/print_string.cpp` and
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index 5d961854cb..5c635de25c 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -43,11 +43,14 @@
#include "test_curve.h"
#include "test_expression.h"
#include "test_file_access.h"
+#include "test_geometry_2d.h"
#include "test_gradient.h"
#include "test_gui.h"
#include "test_json.h"
#include "test_list.h"
+#include "test_local_vector.h"
#include "test_lru.h"
+#include "test_marshalls.h"
#include "test_math.h"
#include "test_method_bind.h"
#include "test_node_path.h"
diff --git a/tests/test_main.h b/tests/test_main.h
index 983bfde402..8c506a776f 100644
--- a/tests/test_main.h
+++ b/tests/test_main.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_marshalls.h b/tests/test_marshalls.h
new file mode 100644
index 0000000000..6bd916164e
--- /dev/null
+++ b/tests/test_marshalls.h
@@ -0,0 +1,329 @@
+/*************************************************************************/
+/* test_marshalls.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_MARSHALLS_H
+#define TEST_MARSHALLS_H
+
+#include "core/io/marshalls.h"
+
+#include "tests/test_macros.h"
+
+namespace TestMarshalls {
+
+TEST_CASE("[Marshalls] Unsigned 16 bit integer encoding") {
+ uint8_t arr[2];
+
+ unsigned int actual_size = encode_uint16(0x1234, arr);
+ CHECK(actual_size == sizeof(uint16_t));
+ CHECK_MESSAGE(arr[0] == 0x34, "First encoded byte value should be equal to low order byte value.");
+ CHECK_MESSAGE(arr[1] == 0x12, "Last encoded byte value should be equal to high order byte value.");
+}
+
+TEST_CASE("[Marshalls] Unsigned 32 bit integer encoding") {
+ uint8_t arr[4];
+
+ unsigned int actual_size = encode_uint32(0x12345678, arr);
+ CHECK(actual_size == sizeof(uint32_t));
+ CHECK_MESSAGE(arr[0] == 0x78, "First encoded byte value should be equal to low order byte value.");
+ CHECK(arr[1] == 0x56);
+ CHECK(arr[2] == 0x34);
+ CHECK_MESSAGE(arr[3] == 0x12, "Last encoded byte value should be equal to high order byte value.");
+}
+
+TEST_CASE("[Marshalls] Unsigned 64 bit integer encoding") {
+ uint8_t arr[8];
+
+ unsigned int actual_size = encode_uint64(0x0f123456789abcdef, arr);
+ CHECK(actual_size == sizeof(uint64_t));
+ CHECK_MESSAGE(arr[0] == 0xef, "First encoded byte value should be equal to low order byte value.");
+ CHECK(arr[1] == 0xcd);
+ CHECK(arr[2] == 0xab);
+ CHECK(arr[3] == 0x89);
+ CHECK(arr[4] == 0x67);
+ CHECK(arr[5] == 0x45);
+ CHECK(arr[6] == 0x23);
+ CHECK_MESSAGE(arr[7] == 0xf1, "Last encoded byte value should be equal to high order byte value.");
+}
+
+TEST_CASE("[Marshalls] Unsigned 16 bit integer decoding") {
+ uint8_t arr[] = { 0x34, 0x12 };
+
+ CHECK(decode_uint16(arr) == 0x1234);
+}
+
+TEST_CASE("[Marshalls] Unsigned 32 bit integer decoding") {
+ uint8_t arr[] = { 0x78, 0x56, 0x34, 0x12 };
+
+ CHECK(decode_uint32(arr) == 0x12345678);
+}
+
+TEST_CASE("[Marshalls] Unsigned 64 bit integer decoding") {
+ uint8_t arr[] = { 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0xf1 };
+
+ CHECK(decode_uint64(arr) == 0x0f123456789abcdef);
+}
+
+TEST_CASE("[Marshalls] Floating point single precision encoding") {
+ uint8_t arr[4];
+
+ // Decimal: 0.15625
+ // IEEE 754 single-precision binary floating-point format:
+ // sign exponent (8 bits) fraction (23 bits)
+ // 0 01111100 01000000000000000000000
+ // Hexadecimal: 0x3E200000
+ unsigned int actual_size = encode_float(0.15625f, arr);
+ CHECK(actual_size == sizeof(uint32_t));
+ CHECK(arr[0] == 0x00);
+ CHECK(arr[1] == 0x00);
+ CHECK(arr[2] == 0x20);
+ CHECK(arr[3] == 0x3e);
+}
+
+TEST_CASE("[Marshalls] Floating point double precision encoding") {
+ uint8_t arr[8];
+
+ // Decimal: 0.333333333333333314829616256247390992939472198486328125
+ // IEEE 754 double-precision binary floating-point format:
+ // sign exponent (11 bits) fraction (52 bits)
+ // 0 01111111101 0101010101010101010101010101010101010101010101010101
+ // Hexadecimal: 0x3FD5555555555555
+ unsigned int actual_size = encode_double(0.33333333333333333, arr);
+ CHECK(actual_size == sizeof(uint64_t));
+ CHECK(arr[0] == 0x55);
+ CHECK(arr[1] == 0x55);
+ CHECK(arr[2] == 0x55);
+ CHECK(arr[3] == 0x55);
+ CHECK(arr[4] == 0x55);
+ CHECK(arr[5] == 0x55);
+ CHECK(arr[6] == 0xd5);
+ CHECK(arr[7] == 0x3f);
+}
+
+TEST_CASE("[Marshalls] Floating point single precision decoding") {
+ uint8_t arr[] = { 0x00, 0x00, 0x20, 0x3e };
+
+ // See floating point encoding test case for details behind expected values
+ CHECK(decode_float(arr) == 0.15625f);
+}
+
+TEST_CASE("[Marshalls] Floating point double precision decoding") {
+ uint8_t arr[] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xd5, 0x3f };
+
+ // See floating point encoding test case for details behind expected values
+ CHECK(decode_double(arr) == 0.33333333333333333);
+}
+
+TEST_CASE("[Marshalls] C string encoding") {
+ char cstring[] = "Godot"; // 5 characters
+ uint8_t data[6];
+
+ int actual_size = encode_cstring(cstring, data);
+ CHECK(actual_size == 6);
+ CHECK(data[0] == 'G');
+ CHECK(data[1] == 'o');
+ CHECK(data[2] == 'd');
+ CHECK(data[3] == 'o');
+ CHECK(data[4] == 't');
+ CHECK(data[5] == '\0');
+}
+
+TEST_CASE("[Marshalls] NIL Variant encoding") {
+ int r_len;
+ Variant variant;
+ uint8_t buffer[4];
+
+ CHECK(encode_variant(variant, buffer, r_len) == OK);
+ CHECK_MESSAGE(r_len == 4, "Length == 4 bytes for Variant::Type");
+ CHECK_MESSAGE(buffer[0] == 0x00, "Variant::NIL");
+ CHECK(buffer[1] == 0x00);
+ CHECK(buffer[2] == 0x00);
+ CHECK(buffer[3] == 0x00);
+ // No value
+}
+
+TEST_CASE("[Marshalls] INT 32 bit Variant encoding") {
+ int r_len;
+ Variant variant(0x12345678);
+ uint8_t buffer[8];
+
+ CHECK(encode_variant(variant, buffer, r_len) == OK);
+ CHECK_MESSAGE(r_len == 8, "Length == 4 bytes for Variant::Type + 4 bytes for int32_t");
+ CHECK_MESSAGE(buffer[0] == 0x02, "Variant::INT");
+ CHECK(buffer[1] == 0x00);
+ CHECK(buffer[2] == 0x00);
+ CHECK(buffer[3] == 0x00);
+ // Check value
+ CHECK(buffer[4] == 0x78);
+ CHECK(buffer[5] == 0x56);
+ CHECK(buffer[6] == 0x34);
+ CHECK(buffer[7] == 0x12);
+}
+
+TEST_CASE("[Marshalls] INT 64 bit Variant encoding") {
+ int r_len;
+ Variant variant(uint64_t(0x0f123456789abcdef));
+ uint8_t buffer[12];
+
+ CHECK(encode_variant(variant, buffer, r_len) == OK);
+ CHECK_MESSAGE(r_len == 12, "Length == 4 bytes for Variant::Type + 8 bytes for int64_t");
+ CHECK_MESSAGE(buffer[0] == 0x02, "Variant::INT");
+ CHECK(buffer[1] == 0x00);
+ CHECK_MESSAGE(buffer[2] == 0x01, "ENCODE_FLAG_64");
+ CHECK(buffer[3] == 0x00);
+ // Check value
+ CHECK(buffer[4] == 0xef);
+ CHECK(buffer[5] == 0xcd);
+ CHECK(buffer[6] == 0xab);
+ CHECK(buffer[7] == 0x89);
+ CHECK(buffer[8] == 0x67);
+ CHECK(buffer[9] == 0x45);
+ CHECK(buffer[10] == 0x23);
+ CHECK(buffer[11] == 0xf1);
+}
+
+TEST_CASE("[Marshalls] FLOAT single precision Variant encoding") {
+ int r_len;
+ Variant variant(0.15625f);
+ uint8_t buffer[8];
+
+ CHECK(encode_variant(variant, buffer, r_len) == OK);
+ CHECK_MESSAGE(r_len == 8, "Length == 4 bytes for Variant::Type + 4 bytes for float");
+ CHECK_MESSAGE(buffer[0] == 0x03, "Variant::FLOAT");
+ CHECK(buffer[1] == 0x00);
+ CHECK(buffer[2] == 0x00);
+ CHECK(buffer[3] == 0x00);
+ // Check value
+ CHECK(buffer[4] == 0x00);
+ CHECK(buffer[5] == 0x00);
+ CHECK(buffer[6] == 0x20);
+ CHECK(buffer[7] == 0x3e);
+}
+
+TEST_CASE("[Marshalls] FLOAT double precision Variant encoding") {
+ int r_len;
+ Variant variant(0.33333333333333333);
+ uint8_t buffer[12];
+
+ CHECK(encode_variant(variant, buffer, r_len) == OK);
+ CHECK_MESSAGE(r_len == 12, "Length == 4 bytes for Variant::Type + 8 bytes for double");
+ CHECK_MESSAGE(buffer[0] == 0x03, "Variant::FLOAT");
+ CHECK(buffer[1] == 0x00);
+ CHECK_MESSAGE(buffer[2] == 0x01, "ENCODE_FLAG_64");
+ CHECK(buffer[3] == 0x00);
+ // Check value
+ CHECK(buffer[4] == 0x55);
+ CHECK(buffer[5] == 0x55);
+ CHECK(buffer[6] == 0x55);
+ CHECK(buffer[7] == 0x55);
+ CHECK(buffer[8] == 0x55);
+ CHECK(buffer[9] == 0x55);
+ CHECK(buffer[10] == 0xd5);
+ CHECK(buffer[11] == 0x3f);
+}
+
+TEST_CASE("[Marshalls] Invalid data Variant decoding") {
+ Variant variant;
+ int r_len = 0;
+ uint8_t some_buffer[1] = { 0x00 };
+ uint8_t out_of_range_type_buffer[4] = { 0xff }; // Greater than Variant::VARIANT_MAX
+
+ CHECK(decode_variant(variant, some_buffer, /* less than 4 */ 1, &r_len) == ERR_INVALID_DATA);
+ CHECK(r_len == 0);
+
+ CHECK(decode_variant(variant, out_of_range_type_buffer, 4, &r_len) == ERR_INVALID_DATA);
+ CHECK(r_len == 0);
+}
+
+TEST_CASE("[Marshalls] NIL Variant decoding") {
+ Variant variant;
+ int r_len;
+ uint8_t buffer[] = {
+ 0x00, 0x00, 0x00, 0x00 // Variant::NIL
+ };
+
+ CHECK(decode_variant(variant, buffer, 4, &r_len) == OK);
+ CHECK(r_len == 4);
+ CHECK(variant == Variant());
+}
+
+TEST_CASE("[Marshalls] INT 32 bit Variant decoding") {
+ Variant variant;
+ int r_len;
+ uint8_t buffer[] = {
+ 0x02, 0x00, 0x00, 0x00, // Variant::INT
+ 0x78, 0x56, 0x34, 0x12 // value
+ };
+
+ CHECK(decode_variant(variant, buffer, 8, &r_len) == OK);
+ CHECK(r_len == 8);
+ CHECK(variant == Variant(0x12345678));
+}
+
+TEST_CASE("[Marshalls] INT 64 bit Variant decoding") {
+ Variant variant;
+ int r_len;
+ uint8_t buffer[] = {
+ 0x02, 0x00, 0x01, 0x00, // Variant::INT & ENCODE_FLAG_64
+ 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0xf1 // value
+ };
+
+ CHECK(decode_variant(variant, buffer, 12, &r_len) == OK);
+ CHECK(r_len == 12);
+ CHECK(variant == Variant(uint64_t(0x0f123456789abcdef)));
+}
+
+TEST_CASE("[Marshalls] FLOAT single precision Variant decoding") {
+ Variant variant;
+ int r_len;
+ uint8_t buffer[] = {
+ 0x03, 0x00, 0x00, 0x00, // Variant::FLOAT
+ 0x00, 0x00, 0x20, 0x3e // value
+ };
+
+ CHECK(decode_variant(variant, buffer, 8, &r_len) == OK);
+ CHECK(r_len == 8);
+ CHECK(variant == Variant(0.15625f));
+}
+
+TEST_CASE("[Marshalls] FLOAT double precision Variant decoding") {
+ Variant variant;
+ int r_len;
+ uint8_t buffer[] = {
+ 0x03, 0x00, 0x01, 0x00, // Variant::FLOAT & ENCODE_FLAG_64
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xd5, 0x3f // value
+ };
+
+ CHECK(decode_variant(variant, buffer, 12, &r_len) == OK);
+ CHECK(r_len == 12);
+ CHECK(variant == Variant(0.33333333333333333));
+}
+} // namespace TestMarshalls
+
+#endif // TEST_MARSHALLS_H
diff --git a/tests/test_math.cpp b/tests/test_math.cpp
index a7f99e5401..26c2aa2088 100644
--- a/tests/test_math.cpp
+++ b/tests/test_math.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -513,7 +513,7 @@ MainLoop *test() {
List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
- if (cmdlargs.empty()) {
+ if (cmdlargs.is_empty()) {
//try editor!
return nullptr;
}
@@ -617,7 +617,7 @@ MainLoop *test() {
List<String> args;
args.push_back("-l");
- Error err = OS::get_singleton()->execute("/bin/ls", args, true, nullptr, &ret);
+ Error err = OS::get_singleton()->execute("/bin/ls", args, &ret);
print_line("error: " + itos(err));
print_line(ret);
diff --git a/tests/test_math.h b/tests/test_math.h
index 77bce8dd66..4375925bd5 100644
--- a/tests/test_math.h
+++ b/tests/test_math.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_method_bind.h b/tests/test_method_bind.h
index 62d8bd132c..879e7949e2 100644
--- a/tests/test_method_bind.h
+++ b/tests/test_method_bind.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_node_path.h b/tests/test_node_path.h
index e9e06186f5..f30fe53c5a 100644
--- a/tests/test_node_path.h
+++ b/tests/test_node_path.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_oa_hash_map.cpp b/tests/test_oa_hash_map.cpp
index b0bb01bc71..904c01642d 100644
--- a/tests/test_oa_hash_map.cpp
+++ b/tests/test_oa_hash_map.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_oa_hash_map.h b/tests/test_oa_hash_map.h
index eb2b3d1e99..9745802cc0 100644
--- a/tests/test_oa_hash_map.h
+++ b/tests/test_oa_hash_map.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_object.h b/tests/test_object.h
index 6fef2576e7..7f310fc096 100644
--- a/tests/test_object.h
+++ b/tests/test_object.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_ordered_hash_map.h b/tests/test_ordered_hash_map.h
index ef26d2531b..fbaaa224cf 100644
--- a/tests/test_ordered_hash_map.h
+++ b/tests/test_ordered_hash_map.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_paged_array.h b/tests/test_paged_array.h
index 6b61160229..7efd3799f3 100644
--- a/tests/test_paged_array.h
+++ b/tests/test_paged_array.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_pck_packer.h b/tests/test_pck_packer.h
index e086d65105..8e4721b821 100644
--- a/tests/test_pck_packer.h
+++ b/tests/test_pck_packer.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_physics_2d.cpp b/tests/test_physics_2d.cpp
index d40df52f1b..570e1897d6 100644
--- a/tests/test_physics_2d.cpp
+++ b/tests/test_physics_2d.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -315,7 +315,7 @@ protected:
}
public:
- virtual void init() override {
+ virtual void initialize() override {
RenderingServer *vs = RenderingServer::get_singleton();
PhysicsServer2D *ps = PhysicsServer2D::get_singleton();
@@ -389,10 +389,10 @@ public:
//_add_plane(Vector2(-1,0).normalized(),-600);
}
- virtual bool idle(float p_time) override {
+ virtual bool process(float p_time) override {
return false;
}
- virtual void finish() override {
+ virtual void finalize() override {
}
TestPhysics2DMainLoop() {}
diff --git a/tests/test_physics_2d.h b/tests/test_physics_2d.h
index 517d324f3b..966d49200a 100644
--- a/tests/test_physics_2d.h
+++ b/tests/test_physics_2d.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_physics_3d.cpp b/tests/test_physics_3d.cpp
index 5f84b2eb50..a11140cfc3 100644
--- a/tests/test_physics_3d.cpp
+++ b/tests/test_physics_3d.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -122,7 +122,7 @@ protected:
ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_BOUNCE, p_bounce);
}
- void init_shapes() {
+ void initialize_shapes() {
RenderingServer *vs = RenderingServer::get_singleton();
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
@@ -269,9 +269,9 @@ public:
virtual void request_quit() {
quit = true;
}
- virtual void init() override {
+ virtual void initialize() override {
ofs_x = ofs_y = 0;
- init_shapes();
+ initialize_shapes();
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
space = ps->space_create();
@@ -310,7 +310,7 @@ public:
test_fall();
quit = false;
}
- virtual bool iteration(float p_time) override {
+ virtual bool physics_process(float p_time) override {
if (mover.is_valid()) {
static float joy_speed = 10;
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
@@ -328,7 +328,7 @@ public:
return quit;
}
- virtual void finish() override {
+ virtual void finalize() override {
}
void test_joint() {
@@ -396,7 +396,7 @@ public:
create_static_plane(Plane(Vector3(0, 1, 0), -1));
}
- virtual bool idle(float p_time) override {
+ virtual bool process(float p_time) override {
return false;
}
diff --git a/tests/test_physics_3d.h b/tests/test_physics_3d.h
index d03f2c6573..b6b66f350e 100644
--- a/tests/test_physics_3d.h
+++ b/tests/test_physics_3d.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_random_number_generator.h b/tests/test_random_number_generator.h
index 999e6d4862..39c4771c19 100644
--- a/tests/test_random_number_generator.h
+++ b/tests/test_random_number_generator.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -73,8 +73,8 @@ TEST_CASE_MAY_FAIL("[RandomNumberGenerator] Integer 32 bit") {
break;
}
}
- INFO("Current seed: " << rng->get_seed());
- INFO("Current iteration: " << i);
+ INFO("Current seed: ", rng->get_seed());
+ INFO("Current iteration: ", i);
CHECK_MESSAGE(higher, "Given current seed, this should give an integer higher than 0x0fff'ffff at least once.");
}
@@ -185,13 +185,13 @@ TEST_CASE("[RandomNumberGenerator] Zero for first number immediately after seedi
rng->set_seed(0);
uint32_t n1 = rng->randi();
uint32_t n2 = rng->randi();
- INFO("Initial random values: " << n1 << " " << n2);
+ INFO("Initial random values: ", n1, " ", n2);
CHECK(n1 != 0);
rng->set_seed(1);
uint32_t n3 = rng->randi();
uint32_t n4 = rng->randi();
- INFO("Values after changing the seed: " << n3 << " " << n4);
+ INFO("Values after changing the seed: ", n3, " ", n4);
CHECK(n3 != 0);
}
@@ -199,7 +199,7 @@ TEST_CASE("[RandomNumberGenerator] Restore state") {
Ref<RandomNumberGenerator> rng = memnew(RandomNumberGenerator);
rng->randomize();
uint64_t last_seed = rng->get_seed();
- INFO("Current seed: " << last_seed);
+ INFO("Current seed: ", last_seed);
rng->randi();
rng->randi();
@@ -208,18 +208,18 @@ TEST_CASE("[RandomNumberGenerator] Restore state") {
"The seed should remain the same after generating some numbers");
uint64_t saved_state = rng->get_state();
- INFO("Current state: " << saved_state);
+ INFO("Current state: ", saved_state);
real_t f1_before = rng->randf();
real_t f2_before = rng->randf();
- INFO("This seed produces: " << f1_before << " " << f2_before);
+ INFO("This seed produces: ", f1_before, " ", f2_before);
// Restore now.
rng->set_state(saved_state);
real_t f1_after = rng->randf();
real_t f2_after = rng->randf();
- INFO("Resetting the state produces: " << f1_after << " " << f2_after);
+ INFO("Resetting the state produces: ", f1_after, " ", f2_after);
String msg = "Should restore the sequence of numbers after resetting the state";
CHECK_MESSAGE(f1_before == f1_after, msg);
@@ -229,22 +229,22 @@ TEST_CASE("[RandomNumberGenerator] Restore state") {
TEST_CASE("[RandomNumberGenerator] Restore from seed") {
Ref<RandomNumberGenerator> rng = memnew(RandomNumberGenerator);
rng->set_seed(0);
- INFO("Current seed: " << rng->get_seed());
+ INFO("Current seed: ", rng->get_seed());
uint32_t s0_1_before = rng->randi();
uint32_t s0_2_before = rng->randi();
- INFO("This seed produces: " << s0_1_before << " " << s0_2_before);
+ INFO("This seed produces: ", s0_1_before, " ", s0_2_before);
rng->set_seed(9000);
- INFO("Current seed: " << rng->get_seed());
+ INFO("Current seed: ", rng->get_seed());
uint32_t s9000_1 = rng->randi();
uint32_t s9000_2 = rng->randi();
- INFO("This seed produces: " << s9000_1 << " " << s9000_2);
+ INFO("This seed produces: ", s9000_1, " ", s9000_2);
rng->set_seed(0);
- INFO("Current seed: " << rng->get_seed());
+ INFO("Current seed: ", rng->get_seed());
uint32_t s0_1_after = rng->randi();
uint32_t s0_2_after = rng->randi();
- INFO("This seed produces: " << s0_1_after << " " << s0_2_after);
+ INFO("This seed produces: ", s0_1_after, " ", s0_2_after);
String msg = "Should restore the sequence of numbers after resetting the seed";
CHECK_MESSAGE(s0_1_before == s0_1_after, msg);
diff --git a/tests/test_rect2.h b/tests/test_rect2.h
index b6edc9ce81..b94a8b7d05 100644
--- a/tests/test_rect2.h
+++ b/tests/test_rect2.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -197,11 +197,11 @@ TEST_CASE("[Rect2] Growing") {
"grow_individual() with positive and negative values should return the expected Rect2.");
CHECK_MESSAGE(
- Rect2(0, 100, 1280, 720).grow_margin(SIDE_TOP, 500).is_equal_approx(Rect2(0, -400, 1280, 1220)),
- "grow_margin() with positive value should return the expected Rect2.");
+ Rect2(0, 100, 1280, 720).grow_side(SIDE_TOP, 500).is_equal_approx(Rect2(0, -400, 1280, 1220)),
+ "grow_side() with positive value should return the expected Rect2.");
CHECK_MESSAGE(
- Rect2(0, 100, 1280, 720).grow_margin(SIDE_TOP, -500).is_equal_approx(Rect2(0, 600, 1280, 220)),
- "grow_margin() with negative value should return the expected Rect2.");
+ Rect2(0, 100, 1280, 720).grow_side(SIDE_TOP, -500).is_equal_approx(Rect2(0, 600, 1280, 220)),
+ "grow_side() with negative value should return the expected Rect2.");
}
TEST_CASE("[Rect2] Has point") {
@@ -409,11 +409,11 @@ TEST_CASE("[Rect2i] Growing") {
"grow_individual() with positive and negative values should return the expected Rect2i.");
CHECK_MESSAGE(
- Rect2i(0, 100, 1280, 720).grow_margin(SIDE_TOP, 500) == Rect2i(0, -400, 1280, 1220),
- "grow_margin() with positive value should return the expected Rect2i.");
+ Rect2i(0, 100, 1280, 720).grow_side(SIDE_TOP, 500) == Rect2i(0, -400, 1280, 1220),
+ "grow_side() with positive value should return the expected Rect2i.");
CHECK_MESSAGE(
- Rect2i(0, 100, 1280, 720).grow_margin(SIDE_TOP, -500) == Rect2i(0, 600, 1280, 220),
- "grow_margin() with negative value should return the expected Rect2i.");
+ Rect2i(0, 100, 1280, 720).grow_side(SIDE_TOP, -500) == Rect2i(0, 600, 1280, 220),
+ "grow_side() with negative value should return the expected Rect2i.");
}
TEST_CASE("[Rect2i] Has point") {
diff --git a/tests/test_render.cpp b/tests/test_render.cpp
index d14251bc6a..2a4ae8bd73 100644
--- a/tests/test_render.cpp
+++ b/tests/test_render.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_render.h b/tests/test_render.h
index 4a6340c443..35bb383773 100644
--- a/tests/test_render.h
+++ b/tests/test_render.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_shader_lang.cpp b/tests/test_shader_lang.cpp
index e79c83b001..a023f35506 100644
--- a/tests/test_shader_lang.cpp
+++ b/tests/test_shader_lang.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -308,7 +308,7 @@ static Error recreate_code(void *p_str, SL::ShaderNode *p_program) {
MainLoop *test() {
List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
- if (cmdlargs.empty()) {
+ if (cmdlargs.is_empty()) {
//try editor!
print_line("usage: godot -test shader_lang <shader>");
return nullptr;
diff --git a/tests/test_shader_lang.h b/tests/test_shader_lang.h
index 2811c5f46e..46a2e6af35 100644
--- a/tests/test_shader_lang.h
+++ b/tests/test_shader_lang.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/tests/test_string.h b/tests/test_string.h
index 3c5d4a2f01..17a2df190d 100644
--- a/tests/test_string.h
+++ b/tests/test_string.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -244,11 +244,11 @@ TEST_CASE("[String] Testing size and length of string") {
}
TEST_CASE("[String] Testing for empty string") {
- CHECK(!String("Mellon").empty());
+ CHECK(!String("Mellon").is_empty());
// do this more than once, to check for string corruption
- CHECK(String("").empty());
- CHECK(String("").empty());
- CHECK(String("").empty());
+ CHECK(String("").is_empty());
+ CHECK(String("").is_empty());
+ CHECK(String("").is_empty());
}
TEST_CASE("[String] Test chr") {
diff --git a/tests/test_text_server.h b/tests/test_text_server.h
index a1a97f3211..b0b40447fe 100644
--- a/tests/test_text_server.h
+++ b/tests/test_text_server.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -45,7 +45,7 @@ TEST_SUITE("[[TextServer]") {
SUBCASE("[TextServer] Init") {
for (int i = 0; i < TextServerManager::get_interface_count(); i++) {
TextServer *ts = TextServerManager::initialize(i, err);
- TEST_FAIL_COND((err != OK || ts == nullptr), "Text server " + TextServerManager::get_interface_name(i) + " init failed.");
+ TEST_FAIL_COND((err != OK || ts == nullptr), "Text server ", TextServerManager::get_interface_name(i), " init failed.");
}
}
diff --git a/tests/test_utils.cpp b/tests/test_utils.cpp
new file mode 100644
index 0000000000..1666a257a9
--- /dev/null
+++ b/tests/test_utils.cpp
@@ -0,0 +1,42 @@
+/*************************************************************************/
+/* test_utils.cpp */
+/*************************************************************************/
+/* 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. */
+/*************************************************************************/
+
+#include "test_utils.h"
+
+#include "core/os/os.h"
+
+String TestUtils::get_data_path(const String &p_file) {
+ String data_path = "../tests/data";
+ return get_executable_dir().plus_file(data_path.plus_file(p_file));
+}
+
+String TestUtils::get_executable_dir() {
+ return OS::get_singleton()->get_executable_path().get_base_dir();
+}
diff --git a/tests/test_utils.h b/tests/test_utils.h
new file mode 100644
index 0000000000..f05ab0bdb1
--- /dev/null
+++ b/tests/test_utils.h
@@ -0,0 +1,42 @@
+/*************************************************************************/
+/* test_utils.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_UTILS_H
+#define TEST_UTILS_H
+
+#include "core/string/ustring.h"
+
+namespace TestUtils {
+
+String get_data_path(const String &p_file);
+String get_executable_dir();
+} // namespace TestUtils
+
+#endif // TEST_UTILS_H
diff --git a/tests/test_validate_testing.h b/tests/test_validate_testing.h
index b4ea6eb576..6d3eea724c 100644
--- a/tests/test_validate_testing.h
+++ b/tests/test_validate_testing.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -179,10 +179,8 @@ TEST_SUITE("Validate tests") {
color_arr.push_back(Color(2, 2, 2));
INFO(color_arr);
- INFO("doctest insertion operator << "
- << var << " " << vec2 << " " << rect2 << " " << color);
-
- CHECK(true); // So all above prints.
+ // doctest string concatenation.
+ CHECK_MESSAGE(true, var, " ", vec2, " ", rect2, " ", color);
}
}
diff --git a/tests/test_variant.h b/tests/test_variant.h
index b575f6744d..f8fa852bf4 100644
--- a/tests/test_variant.h
+++ b/tests/test_variant.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */