diff options
Diffstat (limited to 'tests')
65 files changed, 433 insertions, 232 deletions
diff --git a/tests/core/io/test_config_file.h b/tests/core/io/test_config_file.h index f6fbaf9a88..6e393c7a2d 100644 --- a/tests/core/io/test_config_file.h +++ b/tests/core/io/test_config_file.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/io/test_file_access.h b/tests/core/io/test_file_access.h index 4ffc57afe4..eee57048cf 100644 --- a/tests/core/io/test_file_access.h +++ b/tests/core/io/test_file_access.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -53,7 +53,7 @@ TEST_CASE("[FileAccess] CSV read") { REQUIRE(row2.size() == 3); CHECK(row2[0] == "GOOD_EVENING"); CHECK(row2[1] == "Good Evening"); - CHECK(row2[2] == ""); // Use case: not yet translated! + CHECK(row2[2].is_empty()); // Use case: not yet translated! // https://github.com/godotengine/godot/issues/44269 CHECK_MESSAGE(row2[2] != "\"", "Should not parse empty string as a single double quote."); diff --git a/tests/core/io/test_image.h b/tests/core/io/test_image.h index c4c5f1e18b..dcf21dd7b0 100644 --- a/tests/core/io/test_image.h +++ b/tests/core/io/test_image.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -52,6 +52,13 @@ TEST_CASE("[Image] Instantiation") { "A newly created image should not be compressed."); CHECK(!image->has_mipmaps()); + PackedByteArray image_data = image->get_data(); + for (int i = 0; i < image_data.size(); i++) { + CHECK_MESSAGE( + image_data[i] == 0, + "An image created without data specified should have its data zeroed out."); + } + Ref<Image> image_copy = memnew(Image()); CHECK_MESSAGE( image_copy->is_empty(), @@ -62,7 +69,7 @@ TEST_CASE("[Image] Instantiation") { image->get_data() == image_copy->get_data(), "Duplicated images should have the same data."); - PackedByteArray image_data = image->get_data(); + image_data = image->get_data(); Ref<Image> image_from_data = memnew(Image(8, 4, false, Image::FORMAT_RGBA8, image_data)); CHECK_MESSAGE( image->get_data() == image_from_data->get_data(), @@ -214,14 +221,51 @@ TEST_CASE("[Image] Modifying pixels of an image") { // Fill image with color image2->fill(Color(0.5, 0.5, 0.5, 0.5)); - for (int x = 0; x < image2->get_width(); x++) { - for (int y = 0; y < image2->get_height(); y++) { + for (int y = 0; y < image2->get_height(); y++) { + for (int x = 0; x < image2->get_width(); x++) { CHECK_MESSAGE( image2->get_pixel(x, y).r > 0.49, "fill() should colorize all pixels of the image."); } } + // Fill rect with color + { + const int img_width = 3; + const int img_height = 3; + Vector<Rect2> rects; + rects.push_back(Rect2()); + rects.push_back(Rect2(-5, -5, 3, 3)); + rects.push_back(Rect2(img_width, 0, 12, 12)); + rects.push_back(Rect2(0, img_height, 12, 12)); + rects.push_back(Rect2(img_width + 1, img_height + 2, 12, 12)); + rects.push_back(Rect2(1, 1, 1, 1)); + rects.push_back(Rect2(0, 1, 2, 3)); + rects.push_back(Rect2(-5, 0, img_width + 10, 2)); + rects.push_back(Rect2(0, -5, 2, img_height + 10)); + rects.push_back(Rect2(-1, -1, img_width + 1, img_height + 1)); + + for (const Rect2 &rect : rects) { + Ref<Image> img = memnew(Image(img_width, img_height, false, Image::FORMAT_RGBA8)); + CHECK_NOTHROW_MESSAGE( + img->fill_rect(rect, Color(1, 1, 1, 1)), + "fill_rect() shouldn't throw for any rect."); + for (int y = 0; y < img->get_height(); y++) { + for (int x = 0; x < img->get_width(); x++) { + if (rect.abs().has_point(Point2(x, y))) { + CHECK_MESSAGE( + img->get_pixel(x, y).is_equal_approx(Color(1, 1, 1, 1)), + "fill_rect() should colorize all image pixels within rect bounds."); + } else { + CHECK_MESSAGE( + !img->get_pixel(x, y).is_equal_approx(Color(1, 1, 1, 1)), + "fill_rect() shouldn't colorize any image pixel out of rect bounds."); + } + } + } + } + } + // Blend two images together image->blend_rect(image2, Rect2(Vector2(0, 0), image2->get_size()), Vector2(0, 0)); CHECK_MESSAGE( diff --git a/tests/core/io/test_json.h b/tests/core/io/test_json.h index 3af58dfa1c..478cf1766e 100644 --- a/tests/core/io/test_json.h +++ b/tests/core/io/test_json.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/io/test_marshalls.h b/tests/core/io/test_marshalls.h index 6bd916164e..546a2e9358 100644 --- a/tests/core/io/test_marshalls.h +++ b/tests/core/io/test_marshalls.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/io/test_pck_packer.h b/tests/core/io/test_pck_packer.h index 75a4abffbe..95adca6d68 100644 --- a/tests/core/io/test_pck_packer.h +++ b/tests/core/io/test_pck_packer.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/io/test_resource.h b/tests/core/io/test_resource.h index cee3281995..b3983bb06d 100644 --- a/tests/core/io/test_resource.h +++ b/tests/core/io/test_resource.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/io/test_xml_parser.h b/tests/core/io/test_xml_parser.h index 2d00f29ddf..87592b56ce 100644 --- a/tests/core/io/test_xml_parser.h +++ b/tests/core/io/test_xml_parser.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/math/test_aabb.h b/tests/core/math/test_aabb.h index b838bed171..526972a82f 100644 --- a/tests/core/math/test_aabb.h +++ b/tests/core/math/test_aabb.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -349,14 +349,27 @@ TEST_CASE("[AABB] Has point") { aabb.has_point(Vector3(2, 3, 0)), "has_point() with contained point should return the expected value."); CHECK_MESSAGE( + !aabb.has_point(Vector3(-20, 0, 0)), + "has_point() with non-contained point should return the expected value."); + + CHECK_MESSAGE( aabb.has_point(Vector3(-1.5, 3, 0)), - "has_point() with contained point on negative edge should return the expected value."); + "has_point() with positive size should include point on near face (X axis)."); CHECK_MESSAGE( aabb.has_point(Vector3(2.5, 3, 0)), - "has_point() with contained point on positive edge should return the expected value."); + "has_point() with positive size should include point on far face (X axis)."); CHECK_MESSAGE( - !aabb.has_point(Vector3(-20, 0, 0)), - "has_point() with non-contained point should return the expected value."); + aabb.has_point(Vector3(0, 2, 0)), + "has_point() with positive size should include point on near face (Y axis)."); + CHECK_MESSAGE( + aabb.has_point(Vector3(0, 7, 0)), + "has_point() with positive size should include point on far face (Y axis)."); + CHECK_MESSAGE( + aabb.has_point(Vector3(0, 3, -2.5)), + "has_point() with positive size should include point on near face (Z axis)."); + CHECK_MESSAGE( + aabb.has_point(Vector3(0, 3, 3.5)), + "has_point() with positive size should include point on far face (Z axis)."); } TEST_CASE("[AABB] Expanding") { diff --git a/tests/core/math/test_astar.h b/tests/core/math/test_astar.h index 2c183374ac..859172dca3 100644 --- a/tests/core/math/test_astar.h +++ b/tests/core/math/test_astar.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/math/test_basis.h b/tests/core/math/test_basis.h index 500c069a33..257e41e82c 100644 --- a/tests/core/math/test_basis.h +++ b/tests/core/math/test_basis.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/math/test_color.h b/tests/core/math/test_color.h index 82cf786f7a..e62ce6ec60 100644 --- a/tests/core/math/test_color.h +++ b/tests/core/math/test_color.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/math/test_expression.h b/tests/core/math/test_expression.h index cb1d29389f..5a894b20f3 100644 --- a/tests/core/math/test_expression.h +++ b/tests/core/math/test_expression.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/math/test_geometry_2d.h b/tests/core/math/test_geometry_2d.h index 8f6669b572..3487e4d7e8 100644 --- a/tests/core/math/test_geometry_2d.h +++ b/tests/core/math/test_geometry_2d.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/math/test_geometry_3d.h b/tests/core/math/test_geometry_3d.h index f42003ffcf..1b8d2eee34 100644 --- a/tests/core/math/test_geometry_3d.h +++ b/tests/core/math/test_geometry_3d.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/math/test_math.cpp b/tests/core/math/test_math.cpp index 6ec9bc2473..7b1f3af2b9 100644 --- a/tests/core/math/test_math.cpp +++ b/tests/core/math/test_math.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -312,7 +312,7 @@ public: } } - if (name != String()) { + if (!name.is_empty()) { namespace_stack[at_level] = name; } diff --git a/tests/core/math/test_math.h b/tests/core/math/test_math.h index ab5fb6a050..a8aa8f6847 100644 --- a/tests/core/math/test_math.h +++ b/tests/core/math/test_math.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/math/test_random_number_generator.h b/tests/core/math/test_random_number_generator.h index 39c4771c19..e8cd47b9d7 100644 --- a/tests/core/math/test_random_number_generator.h +++ b/tests/core/math/test_random_number_generator.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/math/test_rect2.h b/tests/core/math/test_rect2.h index aabb950461..e07250a8a2 100644 --- a/tests/core/math/test_rect2.h +++ b/tests/core/math/test_rect2.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/object/test_class_db.h b/tests/core/object/test_class_db.h index 4b27905485..e4145c8408 100644 --- a/tests/core/object/test_class_db.h +++ b/tests/core/object/test_class_db.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/object/test_method_bind.h b/tests/core/object/test_method_bind.h index c3a869a8a4..0c7e47fc89 100644 --- a/tests/core/object/test_method_bind.h +++ b/tests/core/object/test_method_bind.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/object/test_object.h b/tests/core/object/test_object.h index 4109ea521a..f9158eccec 100644 --- a/tests/core/object/test_object.h +++ b/tests/core/object/test_object.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/string/test_node_path.h b/tests/core/string/test_node_path.h index 0216a30f8f..d2de766889 100644 --- a/tests/core/string/test_node_path.h +++ b/tests/core/string/test_node_path.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/string/test_string.h b/tests/core/string/test_string.h index 00a9a8779a..2f611c26a9 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -157,10 +157,10 @@ TEST_CASE("[String] Invalid UTF8") { String s; bool err = s.parse_utf8((const char *)u8str); CHECK(err); - CHECK(s == String()); + CHECK(s.is_empty()); CharString cs = (const char *)u8str; - CHECK(String::utf8(cs) == String()); + CHECK(String::utf8(cs).is_empty()); ERR_PRINT_ON } @@ -170,10 +170,10 @@ TEST_CASE("[String] Invalid UTF16") { String s; bool err = s.parse_utf16(u16str); CHECK(err); - CHECK(s == String()); + CHECK(s.is_empty()); Char16String cs = u16str; - CHECK(String::utf16(cs) == String()); + CHECK(String::utf16(cs).is_empty()); ERR_PRINT_ON } @@ -1132,6 +1132,25 @@ TEST_CASE("[String] c-escape/unescape") { CHECK(s.c_escape().c_unescape() == s); } +TEST_CASE("[String] indent") { + static const char *input[] = { + "", + "aaa\nbbb", + "\tcontains\n\tindent", + "empty\n\nline", + }; + static const char *expected[] = { + "", + "\taaa\n\tbbb", + "\t\tcontains\n\t\tindent", + "\tempty\n\n\tline", + }; + + for (int i = 0; i < 3; i++) { + CHECK(String(input[i]).indent("\t") == expected[i]); + } +} + TEST_CASE("[String] dedent") { String s = " aaa\n bbb"; String t = "aaa\nbbb"; @@ -1439,6 +1458,24 @@ TEST_CASE("[String] Variant ptr indexed set") { CHECK_EQ(s, String("azcd")); } + +TEST_CASE("[Stress][String] Empty via ' == String()'") { + for (int i = 0; i < 100000; ++i) { + String str = "Hello World!"; + if (str.is_empty()) { + continue; + } + } +} + +TEST_CASE("[Stress][String] Empty via `is_empty()`") { + for (int i = 0; i < 100000; ++i) { + String str = "Hello World!"; + if (str.is_empty()) { + continue; + } + } +} } // namespace TestString #endif // TEST_STRING_H diff --git a/tests/core/string/test_translation.h b/tests/core/string/test_translation.h index 47e06add40..85ac639bec 100644 --- a/tests/core/string/test_translation.h +++ b/tests/core/string/test_translation.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/templates/test_command_queue.h b/tests/core/templates/test_command_queue.h index 5d228f2bf6..0d016f5d06 100644 --- a/tests/core/templates/test_command_queue.h +++ b/tests/core/templates/test_command_queue.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/templates/test_list.h b/tests/core/templates/test_list.h index 52d5edff70..49da0b8aad 100644 --- a/tests/core/templates/test_list.h +++ b/tests/core/templates/test_list.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/templates/test_local_vector.h b/tests/core/templates/test_local_vector.h index eff2a16abc..ca4a69b069 100644 --- a/tests/core/templates/test_local_vector.h +++ b/tests/core/templates/test_local_vector.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -84,25 +84,25 @@ TEST_CASE("[LocalVector] Remove.") { vector.push_back(3); vector.push_back(4); - vector.remove(0); + vector.remove_at(0); CHECK(vector[0] == 1); CHECK(vector[1] == 2); CHECK(vector[2] == 3); CHECK(vector[3] == 4); - vector.remove(2); + vector.remove_at(2); CHECK(vector[0] == 1); CHECK(vector[1] == 2); CHECK(vector[2] == 4); - vector.remove(1); + vector.remove_at(1); CHECK(vector[0] == 1); CHECK(vector[1] == 4); - vector.remove(0); + vector.remove_at(0); CHECK(vector[0] == 4); } @@ -117,7 +117,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.size() == 5); - vector.remove_unordered(0); + vector.remove_at_unordered(0); CHECK(vector.size() == 4); @@ -128,7 +128,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.find(4) != -1); // Now the vector is no more ordered. - vector.remove_unordered(vector.find(3)); + vector.remove_at_unordered(vector.find(3)); CHECK(vector.size() == 3); @@ -137,7 +137,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.find(2) != -1); CHECK(vector.find(4) != -1); - vector.remove_unordered(vector.find(2)); + vector.remove_at_unordered(vector.find(2)); CHECK(vector.size() == 2); @@ -145,7 +145,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.find(1) != -1); CHECK(vector.find(4) != -1); - vector.remove_unordered(vector.find(4)); + vector.remove_at_unordered(vector.find(4)); CHECK(vector.size() == 1); @@ -153,7 +153,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.find(1) != -1); // Remove the last one. - vector.remove_unordered(0); + vector.remove_at_unordered(0); CHECK(vector.is_empty()); CHECK(vector.size() == 0); @@ -193,9 +193,9 @@ TEST_CASE("[LocalVector] Size / Resize / Reserve.") { // Capacity is supposed to change only when the size increase. CHECK(vector.get_capacity() >= 10); - vector.remove(0); - vector.remove(0); - vector.remove(0); + vector.remove_at(0); + vector.remove_at(0); + vector.remove_at(0); CHECK(vector.size() == 2); // Capacity is supposed to change only when the size increase. diff --git a/tests/core/templates/test_lru.h b/tests/core/templates/test_lru.h index 9359909c53..354f53e164 100644 --- a/tests/core/templates/test_lru.h +++ b/tests/core/templates/test_lru.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/templates/test_oa_hash_map.cpp b/tests/core/templates/test_oa_hash_map.cpp index 904c01642d..87bf9feb83 100644 --- a/tests/core/templates/test_oa_hash_map.cpp +++ b/tests/core/templates/test_oa_hash_map.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -55,7 +55,10 @@ struct CountedItem { count++; } - CountedItem &operator=(const CountedItem &p_other) = default; + void operator=(const CountedItem &p_other) { + id = p_other.id; + count++; + } ~CountedItem() { CRASH_COND(destroyed); diff --git a/tests/core/templates/test_oa_hash_map.h b/tests/core/templates/test_oa_hash_map.h index f229ac94ea..d4b72af2ac 100644 --- a/tests/core/templates/test_oa_hash_map.h +++ b/tests/core/templates/test_oa_hash_map.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/templates/test_ordered_hash_map.h b/tests/core/templates/test_ordered_hash_map.h index 35ce0fc656..08c5c9b72a 100644 --- a/tests/core/templates/test_ordered_hash_map.h +++ b/tests/core/templates/test_ordered_hash_map.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/templates/test_paged_array.h b/tests/core/templates/test_paged_array.h index 7efd3799f3..86cf3a2dfc 100644 --- a/tests/core/templates/test_paged_array.h +++ b/tests/core/templates/test_paged_array.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/templates/test_vector.h b/tests/core/templates/test_vector.h index bfdf389aa7..b0dcff93fd 100644 --- a/tests/core/templates/test_vector.h +++ b/tests/core/templates/test_vector.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -129,7 +129,7 @@ TEST_CASE("[Vector] Fill large array and modify it") { CHECK(vector[200] == 0); CHECK(vector[499'999] == 0x60d07); CHECK(vector[999'999] == 0x60d07); - vector.remove(200); + vector.remove_at(200); CHECK(vector[200] == 0x60d07); vector.clear(); @@ -145,7 +145,7 @@ TEST_CASE("[Vector] Copy creation") { vector.push_back(4); Vector<int> vector_other = Vector<int>(vector); - vector_other.remove(0); + vector_other.remove_at(0); CHECK(vector_other[0] == 1); CHECK(vector_other[1] == 2); CHECK(vector_other[2] == 3); @@ -168,7 +168,7 @@ TEST_CASE("[Vector] Duplicate") { vector.push_back(4); Vector<int> vector_other = vector.duplicate(); - vector_other.remove(0); + vector_other.remove_at(0); CHECK(vector_other[0] == 1); CHECK(vector_other[1] == 2); CHECK(vector_other[2] == 3); @@ -238,7 +238,7 @@ TEST_CASE("[Vector] To byte array") { CHECK(byte_array[15] == 59); } -TEST_CASE("[Vector] Subarray") { +TEST_CASE("[Vector] Slice") { Vector<int> vector; vector.push_back(0); vector.push_back(1); @@ -246,27 +246,27 @@ TEST_CASE("[Vector] Subarray") { vector.push_back(3); vector.push_back(4); - Vector<int> subarray1 = vector.subarray(1, 2); - CHECK(subarray1.size() == 2); - CHECK(subarray1[0] == 1); - CHECK(subarray1[1] == 2); - - Vector<int> subarray2 = vector.subarray(1, -1); - CHECK(subarray2.size() == 4); - CHECK(subarray2[0] == 1); - CHECK(subarray2[1] == 2); - CHECK(subarray2[2] == 3); - CHECK(subarray2[3] == 4); - - Vector<int> subarray3 = vector.subarray(-2, -1); - CHECK(subarray3.size() == 2); - CHECK(subarray3[0] == 3); - CHECK(subarray3[1] == 4); - - Vector<int> subarray4 = vector.subarray(-3, 3); - CHECK(subarray4.size() == 2); - CHECK(subarray4[0] == 2); - CHECK(subarray4[1] == 3); + Vector<int> slice1 = vector.slice(1, 3); + CHECK(slice1.size() == 2); + CHECK(slice1[0] == 1); + CHECK(slice1[1] == 2); + + Vector<int> slice2 = vector.slice(1, -1); + CHECK(slice2.size() == 4); + CHECK(slice2[0] == 1); + CHECK(slice2[1] == 2); + CHECK(slice2[2] == 3); + CHECK(slice2[3] == 4); + + Vector<int> slice3 = vector.slice(3, -1); + CHECK(slice3.size() == 2); + CHECK(slice3[0] == 3); + CHECK(slice3[1] == 4); + + Vector<int> slice4 = vector.slice(2, -2); + CHECK(slice4.size() == 2); + CHECK(slice4[0] == 2); + CHECK(slice4[1] == 3); } TEST_CASE("[Vector] Find, has") { @@ -302,7 +302,7 @@ TEST_CASE("[Vector] Find, has") { CHECK(!vector.has(5)); } -TEST_CASE("[Vector] Remove") { +TEST_CASE("[Vector] Remove at") { Vector<int> vector; vector.push_back(0); vector.push_back(1); @@ -310,30 +310,30 @@ TEST_CASE("[Vector] Remove") { vector.push_back(3); vector.push_back(4); - vector.remove(0); + vector.remove_at(0); CHECK(vector[0] == 1); CHECK(vector[1] == 2); CHECK(vector[2] == 3); CHECK(vector[3] == 4); - vector.remove(2); + vector.remove_at(2); CHECK(vector[0] == 1); CHECK(vector[1] == 2); CHECK(vector[2] == 4); - vector.remove(1); + vector.remove_at(1); CHECK(vector[0] == 1); CHECK(vector[1] == 4); - vector.remove(0); + vector.remove_at(0); CHECK(vector[0] == 4); } -TEST_CASE("[Vector] Remove and find") { +TEST_CASE("[Vector] Remove at and find") { Vector<int> vector; vector.push_back(0); vector.push_back(1); @@ -343,7 +343,7 @@ TEST_CASE("[Vector] Remove and find") { CHECK(vector.size() == 5); - vector.remove(0); + vector.remove_at(0); CHECK(vector.size() == 4); @@ -353,7 +353,7 @@ TEST_CASE("[Vector] Remove and find") { CHECK(vector.find(3) != -1); CHECK(vector.find(4) != -1); - vector.remove(vector.find(3)); + vector.remove_at(vector.find(3)); CHECK(vector.size() == 3); @@ -362,7 +362,7 @@ TEST_CASE("[Vector] Remove and find") { CHECK(vector.find(2) != -1); CHECK(vector.find(4) != -1); - vector.remove(vector.find(2)); + vector.remove_at(vector.find(2)); CHECK(vector.size() == 2); @@ -370,14 +370,14 @@ TEST_CASE("[Vector] Remove and find") { CHECK(vector.find(1) != -1); CHECK(vector.find(4) != -1); - vector.remove(vector.find(4)); + vector.remove_at(vector.find(4)); CHECK(vector.size() == 1); CHECK(vector.find(4) == -1); CHECK(vector.find(1) != -1); - vector.remove(0); + vector.remove_at(0); CHECK(vector.is_empty()); CHECK(vector.size() == 0); @@ -412,9 +412,9 @@ TEST_CASE("[Vector] Size, resize, reserve") { CHECK(vector.size() == 5); - vector.remove(0); - vector.remove(0); - vector.remove(0); + vector.remove_at(0); + vector.remove_at(0); + vector.remove_at(0); CHECK(vector.size() == 2); diff --git a/tests/core/test_crypto.h b/tests/core/test_crypto.h index 3b909c7df8..ce4edc71ae 100644 --- a/tests/core/test_crypto.h +++ b/tests/core/test_crypto.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/test_hashing_context.h b/tests/core/test_hashing_context.h index 728a5f2cfa..4795d24103 100644 --- a/tests/core/test_hashing_context.h +++ b/tests/core/test_hashing_context.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/test_time.h b/tests/core/test_time.h index 28f1cb2f20..903ca9c001 100644 --- a/tests/core/test_time.h +++ b/tests/core/test_time.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/variant/test_array.h b/tests/core/variant/test_array.h index 298bd2ff63..205e34daea 100644 --- a/tests/core/variant/test_array.h +++ b/tests/core/variant/test_array.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -129,20 +129,20 @@ TEST_CASE("[Array] has() and count()") { CHECK(arr.count(2) == 0); } -TEST_CASE("[Array] remove()") { +TEST_CASE("[Array] remove_at()") { Array arr; arr.push_back(1); arr.push_back(2); - arr.remove(0); + arr.remove_at(0); CHECK(arr.size() == 1); CHECK(int(arr[0]) == 2); - arr.remove(0); + arr.remove_at(0); CHECK(arr.size() == 0); - // The array is now empty; try to use `remove()` again. + // The array is now empty; try to use `remove_at()` again. // Normally, this prints an error message so we silence it. ERR_PRINT_OFF; - arr.remove(0); + arr.remove_at(0); ERR_PRINT_ON; CHECK(arr.size() == 0); @@ -246,6 +246,37 @@ TEST_CASE("[Array] max() and min()") { CHECK(min == 2); } +TEST_CASE("[Array] slice()") { + Array array; + array.push_back(0); + array.push_back(1); + array.push_back(2); + array.push_back(3); + array.push_back(4); + + Array slice1 = array.slice(1, 3); + CHECK(slice1.size() == 2); + CHECK(slice1[0] == Variant(1)); + CHECK(slice1[1] == Variant(2)); + + Array slice2 = array.slice(1, -1); + CHECK(slice2.size() == 4); + CHECK(slice2[0] == Variant(1)); + CHECK(slice2[1] == Variant(2)); + CHECK(slice2[2] == Variant(3)); + CHECK(slice2[3] == Variant(4)); + + Array slice3 = array.slice(3, -1); + CHECK(slice3.size() == 2); + CHECK(slice3[0] == Variant(3)); + CHECK(slice3[1] == Variant(4)); + + Array slice4 = array.slice(2, -2); + CHECK(slice4.size() == 2); + CHECK(slice4[0] == Variant(2)); + CHECK(slice4[1] == Variant(3)); +} + TEST_CASE("[Array] Duplicate array") { // a = [1, [2, 2], {3: 3}] Array a = build_array(1, build_array(2, 2), build_dictionary(3, 3)); diff --git a/tests/core/variant/test_dictionary.h b/tests/core/variant/test_dictionary.h index 65079698a3..79d53fa64e 100644 --- a/tests/core/variant/test_dictionary.h +++ b/tests/core/variant/test_dictionary.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/core/variant/test_variant.h b/tests/core/variant/test_variant.h index 0d16fa092c..916686d7c1 100644 --- a/tests/core/variant/test_variant.h +++ b/tests/core/variant/test_variant.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/scene/test_code_edit.h b/tests/scene/test_code_edit.h index a95dd02ba5..52d3d5c340 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -1104,7 +1104,7 @@ TEST_CASE("[SceneTree][CodeEdit] delimiters") { CHECK(code_edit->get_delimiter_start_key(idx) == "#"); CHECK(code_edit->get_delimiter_end_key(idx) == ""); - /* Check nested strings are handeled correctly. */ + /* Check nested strings are handled correctly. */ code_edit->set_text(" \n# # \n "); /* Check line above is not in string. */ @@ -1132,7 +1132,7 @@ TEST_CASE("[SceneTree][CodeEdit] delimiters") { CHECK(code_edit->get_delimiter_start_position(2, 1) == OUTSIDE_DELIMETER); CHECK(code_edit->get_delimiter_end_position(2, 1) == OUTSIDE_DELIMETER); - /* Check is in string with no column retruns true if entire line is comment excluding whitespace. */ + /* Check is in string with no column returns true if entire line is comment excluding whitespace. */ code_edit->set_text(" \n # # \n "); CHECK(code_edit->is_in_string(1) != -1); @@ -1195,7 +1195,7 @@ TEST_CASE("[SceneTree][CodeEdit] delimiters") { CHECK(code_edit->get_delimiter_start_key(idx) == "#"); CHECK(code_edit->get_delimiter_end_key(idx) == ""); - /* Check nested comments are handeled correctly. */ + /* Check nested comments are handled correctly. */ code_edit->set_text(" \n# # \n "); /* Check line above is not in comment. */ @@ -1223,7 +1223,7 @@ TEST_CASE("[SceneTree][CodeEdit] delimiters") { CHECK(code_edit->get_delimiter_start_position(2, 1) == OUTSIDE_DELIMETER); CHECK(code_edit->get_delimiter_end_position(2, 1) == OUTSIDE_DELIMETER); - /* Check is in comment with no column retruns true if entire line is comment excluding whitespace. */ + /* Check is in comment with no column returns true if entire line is comment excluding whitespace. */ code_edit->set_text(" \n # # \n "); CHECK(code_edit->is_in_comment(1) != -1); @@ -1491,7 +1491,7 @@ TEST_CASE("[SceneTree][CodeEdit] delimiters") { CHECK(code_edit->get_delimiter_start_key(idx) == "#"); CHECK(code_edit->get_delimiter_end_key(idx) == "#"); - /* Check is in string with no column retruns true if entire line is string excluding whitespace. */ + /* Check is in string with no column returns true if entire line is string excluding whitespace. */ code_edit->set_text(" \n # \n\n #\n "); CHECK(code_edit->is_in_string(1) != -1); CHECK(code_edit->is_in_string(2) != -1); @@ -1680,7 +1680,7 @@ TEST_CASE("[SceneTree][CodeEdit] delimiters") { CHECK(code_edit->get_delimiter_start_key(idx) == "#"); CHECK(code_edit->get_delimiter_end_key(idx) == "#"); - /* Check is in comment with no column retruns true if entire line is comment excluding whitespace. */ + /* Check is in comment with no column returns true if entire line is comment excluding whitespace. */ code_edit->set_text(" \n # \n\n #\n "); CHECK(code_edit->is_in_comment(1) != -1); CHECK(code_edit->is_in_comment(2) != -1); @@ -1746,7 +1746,7 @@ TEST_CASE("[SceneTree][CodeEdit] delimiters") { CHECK(code_edit->get_delimiter_start_key(idx) == "#"); CHECK(code_edit->get_delimiter_end_key(idx) == "#"); - /* Check is in comment with no column retruns true as inner delimiter should not be counted. */ + /* Check is in comment with no column returns true as inner delimiter should not be counted. */ CHECK(code_edit->is_in_comment(1) != -1); CHECK(code_edit->is_in_comment(2) != -1); CHECK(code_edit->is_in_comment(3) != -1); @@ -2332,6 +2332,20 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { CHECK_FALSE(code_edit->is_line_folded(2)); CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + // Indent with blank lines. + code_edit->set_text("line1\n\tline2\n\n\nline3"); + CHECK(code_edit->can_fold_line(0)); + for (int i = 1; i < 2; i++) { + CHECK_FALSE(code_edit->can_fold_line(i)); + code_edit->fold_line(i); + CHECK_FALSE(code_edit->is_line_folded(i)); + } + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(1)); + CHECK_FALSE(code_edit->is_line_folded(2)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + // Nested indents. code_edit->set_text("line1\n\tline2\n\t\tline3\nline4"); CHECK(code_edit->can_fold_line(0)); @@ -2408,7 +2422,7 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { for (int i = 1; i < code_edit->get_line_count(); i++) { CHECK_FALSE(code_edit->is_line_folded(i)); } - CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 6); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 5); // End of file. code_edit->set_text("line1\n\tline2"); @@ -2490,7 +2504,7 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { // Multiline blocks. code_edit->add_comment_delimiter("&", "&", false); - code_edit->set_text("&line1\n\tline2&"); + code_edit->set_text("&line1\n\tline2&\nline3"); CHECK(code_edit->can_fold_line(0)); CHECK_FALSE(code_edit->can_fold_line(1)); code_edit->fold_line(1); @@ -2498,7 +2512,17 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { code_edit->fold_line(0); CHECK(code_edit->is_line_folded(0)); CHECK_FALSE(code_edit->is_line_folded(1)); - CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 1); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + + // Multiline comment before last line. + code_edit->set_text("&line1\nline2&\ntest"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(2)); + code_edit->fold_line(1); + CHECK_FALSE(code_edit->is_line_folded(1)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); // Has to be full line. code_edit->set_text("test &line1\n\tline2&"); @@ -2554,7 +2578,7 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { CHECK_FALSE(code_edit->is_line_folded(1)); CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 1); - // Non-indented comments/ strings. + // Non-indented comments/strings. // Single line code_edit->set_text("test\n\tline1\n#line1\n#line2\n\ttest"); CHECK(code_edit->can_fold_line(0)); @@ -2576,6 +2600,50 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { CHECK_FALSE(code_edit->is_line_folded(1)); CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 4); + // Indent level 0->1, comment after lines + code_edit->set_text("line1\n\tline2\n#test"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(1)); + code_edit->fold_line(1); + CHECK_FALSE(code_edit->is_line_folded(1)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(1)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + + // Indent level 0->1, comment between lines + code_edit->set_text("line1\n#test\n\tline2\nline3"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(2)); + code_edit->fold_line(2); + CHECK_FALSE(code_edit->is_line_folded(2)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(2)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 3); + + // Indent level 1->2, comment after lines + code_edit->set_text("\tline1\n\t\tline2\n#test"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(1)); + code_edit->fold_line(1); + CHECK_FALSE(code_edit->is_line_folded(1)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(1)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + + // Indent level 1->2, comment between lines + code_edit->set_text("\tline1\n#test\n\t\tline2\nline3"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(2)); + code_edit->fold_line(2); + CHECK_FALSE(code_edit->is_line_folded(2)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(2)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 3); + // Multiline code_edit->set_text("test\n\tline1\n&line1\nline2&\n\ttest"); CHECK(code_edit->can_fold_line(0)); @@ -3167,7 +3235,7 @@ TEST_CASE("[SceneTree][CodeEdit] Backspace delete") { code_edit->insert_text_at_caret("line 1\nline 2\nline 3"); code_edit->select_all(); code_edit->backspace(); - CHECK(code_edit->get_text() == ""); + CHECK(code_edit->get_text().is_empty()); /* Backspace at the beginning without selection has no effect. */ code_edit->set_text(""); diff --git a/tests/scene/test_curve.h b/tests/scene/test_curve.h index 60eafad460..0370ab15fd 100644 --- a/tests/scene/test_curve.h +++ b/tests/scene/test_curve.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -219,35 +219,33 @@ TEST_CASE("[Curve] Custom curve with linear tangents") { TEST_CASE("[Curve2D] Linear sampling should return exact value") { Ref<Curve2D> curve = memnew(Curve2D); - int len = 2048; + real_t len = 2048.0; curve->add_point(Vector2(0, 0)); - curve->add_point(Vector2((float)len, 0)); + curve->add_point(Vector2(len, 0)); - float baked_length = curve->get_baked_length(); - CHECK((float)len == baked_length); + real_t baked_length = curve->get_baked_length(); + CHECK(len == baked_length); for (int i = 0; i < len; i++) { - float expected = (float)i; - Vector2 pos = curve->interpolate_baked(expected); - CHECK_MESSAGE(pos.x == expected, "interpolate_baked should return exact value"); + Vector2 pos = curve->interpolate_baked(i); + CHECK_MESSAGE(pos.x == i, "interpolate_baked should return exact value"); } } TEST_CASE("[Curve3D] Linear sampling should return exact value") { Ref<Curve3D> curve = memnew(Curve3D); - int len = 2048; + real_t len = 2048.0; curve->add_point(Vector3(0, 0, 0)); - curve->add_point(Vector3((float)len, 0, 0)); + curve->add_point(Vector3(len, 0, 0)); - float baked_length = curve->get_baked_length(); - CHECK((float)len == baked_length); + real_t baked_length = curve->get_baked_length(); + CHECK(len == baked_length); for (int i = 0; i < len; i++) { - float expected = (float)i; - Vector3 pos = curve->interpolate_baked(expected); - CHECK_MESSAGE(pos.x == expected, "interpolate_baked should return exact value"); + Vector3 pos = curve->interpolate_baked(i); + CHECK_MESSAGE(pos.x == i, "interpolate_baked should return exact value"); } } diff --git a/tests/scene/test_gradient.h b/tests/scene/test_gradient.h index fc595b02f2..b0e6128932 100644 --- a/tests/scene/test_gradient.h +++ b/tests/scene/test_gradient.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/scene/test_gui.cpp b/tests/scene/test_gui.cpp index 5bd9390cb7..cd5624b70c 100644 --- a/tests/scene/test_gui.cpp +++ b/tests/scene/test_gui.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -69,7 +69,7 @@ public: label->set_position(Point2(80, 90)); label->set_size(Point2(170, 80)); - label->set_align(Label::ALIGN_FILL); + label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_FILL); label->set_text("There was once upon a time a beautiful unicorn that loved to play with little girls..."); frame->add_child(label); diff --git a/tests/scene/test_gui.h b/tests/scene/test_gui.h index 84bce620e2..a1807ed15c 100644 --- a/tests/scene/test_gui.h +++ b/tests/scene/test_gui.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/scene/test_path_3d.h b/tests/scene/test_path_3d.h index 1fcef3adde..78f4e97f03 100644 --- a/tests/scene/test_path_3d.h +++ b/tests/scene/test_path_3d.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/scene/test_path_follow_2d.h b/tests/scene/test_path_follow_2d.h index ddfcc5552a..abd12fe862 100644 --- a/tests/scene/test_path_follow_2d.h +++ b/tests/scene/test_path_follow_2d.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/scene/test_path_follow_3d.h b/tests/scene/test_path_follow_3d.h index 6a505dbb39..9ffe49e3d6 100644 --- a/tests/scene/test_path_follow_3d.h +++ b/tests/scene/test_path_follow_3d.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/servers/test_physics_2d.cpp b/tests/servers/test_physics_2d.cpp index 06aa88b5c0..8b77458a33 100644 --- a/tests/servers/test_physics_2d.cpp +++ b/tests/servers/test_physics_2d.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/servers/test_physics_2d.h b/tests/servers/test_physics_2d.h index 2ae1053a03..b6c47574cd 100644 --- a/tests/servers/test_physics_2d.h +++ b/tests/servers/test_physics_2d.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/servers/test_physics_3d.cpp b/tests/servers/test_physics_3d.cpp index 7cb74b1ee3..3d38b9d901 100644 --- a/tests/servers/test_physics_3d.cpp +++ b/tests/servers/test_physics_3d.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/servers/test_physics_3d.h b/tests/servers/test_physics_3d.h index b86327cdb4..f618d0fb4f 100644 --- a/tests/servers/test_physics_3d.h +++ b/tests/servers/test_physics_3d.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/servers/test_render.cpp b/tests/servers/test_render.cpp index 183f049238..44403e3724 100644 --- a/tests/servers/test_render.cpp +++ b/tests/servers/test_render.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/servers/test_render.h b/tests/servers/test_render.h index 1d773cb347..d5a3e01ee5 100644 --- a/tests/servers/test_render.h +++ b/tests/servers/test_render.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/servers/test_shader_lang.cpp b/tests/servers/test_shader_lang.cpp index 0591bf6adf..acc7e32441 100644 --- a/tests/servers/test_shader_lang.cpp +++ b/tests/servers/test_shader_lang.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -261,6 +261,8 @@ static String dump_node_code(SL::Node *p_node, int p_level) { } code += ")"; break; + case SL::OP_EMPTY: + break; default: { code = "(" + dump_node_code(onode->arguments[0], p_level) + _opstr(onode->op) + dump_node_code(onode->arguments[1], p_level) + ")"; break; @@ -339,12 +341,17 @@ MainLoop *test() { dt["fragment"].built_ins["ALBEDO"] = SL::TYPE_VEC3; dt["fragment"].can_discard = true; - Vector<StringName> rm; - rm.push_back("popo"); + Vector<SL::ModeInfo> rm; + rm.push_back({ "popo" }); Set<String> types; types.insert("spatial"); - Error err = sl.compile(code, dt, rm, ShaderLanguage::VaryingFunctionNames(), types, nullptr); + ShaderLanguage::ShaderCompileInfo info; + info.functions = dt; + info.render_modes = rm; + info.shader_types = types; + + Error err = sl.compile(code, info); if (err) { print_line("Error at line: " + rtos(sl.get_error_line()) + ": " + sl.get_error_text()); diff --git a/tests/servers/test_shader_lang.h b/tests/servers/test_shader_lang.h index de7ec002b6..31e1bfbeea 100644 --- a/tests/servers/test_shader_lang.h +++ b/tests/servers/test_shader_lang.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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/servers/test_text_server.h b/tests/servers/test_text_server.h index 4edffe3711..b06f315bc8 100644 --- a/tests/servers/test_text_server.h +++ b/tests/servers/test_text_server.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 b0b28ab374..aa07f8211a 100644 --- a/tests/test_macros.cpp +++ b/tests/test_macros.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 b04c2117b7..ed8a12f155 100644 --- a/tests/test_macros.h +++ b/tests/test_macros.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -135,7 +135,7 @@ int register_test_command(String p_command, TestFunc p_function); // SEND_GUI_ACTION - takes an object and a input map key. e.g SEND_GUI_ACTION(code_edit, "ui_text_newline"). // SEND_GUI_KEY_EVENT - takes an object and a keycode set. e.g SEND_GUI_KEY_EVENT(code_edit, Key::A | KeyModifierMask::CMD). // SEND_GUI_MOUSE_EVENT - takes an object, position, mouse button and mouse mask e.g SEND_GUI_MOUSE_EVENT(code_edit, Vector2(50, 50), MOUSE_BUTTON_NONE, MOUSE_BUTTON_NONE); -// SEND_GUI_DOUBLE_CLICK - takes an object and a postion. e.g SEND_GUI_DOUBLE_CLICK(code_edit, Vector2(50, 50)); +// SEND_GUI_DOUBLE_CLICK - takes an object and a position. e.g SEND_GUI_DOUBLE_CLICK(code_edit, Vector2(50, 50)); #define SEND_GUI_ACTION(m_object, m_action) \ { \ @@ -192,7 +192,7 @@ int register_test_command(String p_command, TestFunc p_function); // // Use SIGNAL_DISCARD("signal_name") to discard records all of the given signal, use only in placed you don't need to check. // -// All signals are automaticaly discared between test/sub test cases. +// All signals are automatically discarded between test/sub test cases. class SignalWatcher : public Object { private: diff --git a/tests/test_main.cpp b/tests/test_main.cpp index a09be08de8..2b2c89fbf1 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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_main.h b/tests/test_main.h index 8c506a776f..8e6a7361fc 100644 --- a/tests/test_main.h +++ b/tests/test_main.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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_tools.h b/tests/test_tools.h index e1192458d0..8ee7a4718f 100644 --- a/tests/test_tools.h +++ b/tests/test_tools.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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_utils.cpp b/tests/test_utils.cpp index 890dea3ee1..11cb6398aa 100644 --- a/tests/test_utils.cpp +++ b/tests/test_utils.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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_utils.h b/tests/test_utils.h index ccebe2e449..499ddb84b2 100644 --- a/tests/test_utils.h +++ b/tests/test_utils.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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_validate_testing.h b/tests/test_validate_testing.h index 40b255e18a..413a7e351d 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-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ |