summaryrefslogtreecommitdiff
path: root/main/tests
diff options
context:
space:
mode:
Diffstat (limited to 'main/tests')
-rw-r--r--main/tests/SCsub4
-rw-r--r--main/tests/test_astar.cpp (renamed from main/tests/test_image.cpp)100
-rw-r--r--main/tests/test_astar.h (renamed from main/tests/test_io.h)18
-rw-r--r--main/tests/test_gdscript.cpp23
-rw-r--r--main/tests/test_gdscript.h6
-rw-r--r--main/tests/test_gui.cpp14
-rw-r--r--main/tests/test_gui.h6
-rw-r--r--main/tests/test_image.h45
-rw-r--r--main/tests/test_io.cpp133
-rw-r--r--main/tests/test_main.cpp28
-rw-r--r--main/tests/test_main.h8
-rw-r--r--main/tests/test_math.cpp51
-rw-r--r--main/tests/test_math.h6
-rw-r--r--main/tests/test_oa_hash_map.cpp35
-rw-r--r--main/tests/test_oa_hash_map.h6
-rw-r--r--main/tests/test_ordered_hash_map.cpp14
-rw-r--r--main/tests/test_ordered_hash_map.h4
-rw-r--r--main/tests/test_physics.cpp16
-rw-r--r--main/tests/test_physics.h6
-rw-r--r--main/tests/test_physics_2d.cpp12
-rw-r--r--main/tests/test_physics_2d.h6
-rw-r--r--main/tests/test_render.cpp16
-rw-r--r--main/tests/test_render.h6
-rw-r--r--main/tests/test_shader_lang.cpp33
-rw-r--r--main/tests/test_shader_lang.h6
-rw-r--r--main/tests/test_string.cpp295
-rw-r--r--main/tests/test_string.h8
27 files changed, 493 insertions, 412 deletions
diff --git a/main/tests/SCsub b/main/tests/SCsub
index 26a0819ee8..437d9ed777 100644
--- a/main/tests/SCsub
+++ b/main/tests/SCsub
@@ -5,9 +5,5 @@ Import('env')
env.tests_sources = []
env.add_source_files(env.tests_sources, "*.cpp")
-Export('env')
-
-# SConscript('math/SCsub');
-
lib = env.add_library("tests", env.tests_sources)
env.Prepend(LIBS=[lib])
diff --git a/main/tests/test_image.cpp b/main/tests/test_astar.cpp
index cb87458a93..d34ff0d95e 100644
--- a/main/tests/test_image.cpp
+++ b/main/tests/test_astar.cpp
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* test_image.cpp */
+/* test_astar.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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,42 +28,90 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "test_image.h"
+#include "test_astar.h"
-#include "io/image_loader.h"
-#include "math_funcs.h"
-#include "os/main_loop.h"
-#include "print_string.h"
+#include "core/math/a_star.h"
+#include "core/os/os.h"
-namespace TestImage {
+#include <stdio.h>
-class TestMainLoop : public MainLoop {
-
- bool quit;
+namespace TestAStar {
+class ABCX : public AStar {
public:
- virtual void input_event(const Ref<InputEvent> &p_event) {
- }
+ enum { A,
+ B,
+ C,
+ X };
- virtual void init() {
-
- quit = false;
+ ABCX() {
+ add_point(A, Vector3(0, 0, 0));
+ add_point(B, Vector3(1, 0, 0));
+ add_point(C, Vector3(0, 1, 0));
+ add_point(X, Vector3(0, 0, 1));
+ connect_points(A, B);
+ connect_points(A, C);
+ connect_points(B, C);
+ connect_points(X, A);
}
- virtual bool iteration(float p_time) {
- return quit;
+ // Disable heuristic completely
+ float _compute_cost(int p_from, int p_to) {
+ if (p_from == A && p_to == C) {
+ return 1000;
+ }
+ return 100;
}
+};
- virtual bool idle(float p_time) {
- return quit;
- }
+bool test_abc() {
+ ABCX abcx;
+ PoolVector<int> path = abcx.get_id_path(ABCX::A, ABCX::C);
+ bool ok = path.size() == 3;
+ int i = 0;
+ ok = ok && path[i++] == ABCX::A;
+ ok = ok && path[i++] == ABCX::B;
+ ok = ok && path[i++] == ABCX::C;
+ return ok;
+}
- virtual void finish() {
- }
+bool test_abcx() {
+ ABCX abcx;
+ PoolVector<int> path = abcx.get_id_path(ABCX::X, ABCX::C);
+ bool ok = path.size() == 4;
+ int i = 0;
+ ok = ok && path[i++] == ABCX::X;
+ ok = ok && path[i++] == ABCX::A;
+ ok = ok && path[i++] == ABCX::B;
+ ok = ok && path[i++] == ABCX::C;
+ return ok;
+}
+
+typedef bool (*TestFunc)(void);
+
+TestFunc test_funcs[] = {
+ test_abc,
+ test_abcx,
+ NULL
};
MainLoop *test() {
+ int count = 0;
+ int passed = 0;
- return memnew(TestMainLoop);
+ while (true) {
+ if (!test_funcs[count])
+ break;
+ bool pass = test_funcs[count]();
+ if (pass)
+ passed++;
+ OS::get_singleton()->print("\t%s\n", pass ? "PASS" : "FAILED");
+
+ count++;
+ }
+ OS::get_singleton()->print("\n");
+ OS::get_singleton()->print("Passed %i of %i tests\n", passed, count);
+ return NULL;
}
-} // namespace TestImage
+
+} // namespace TestAStar
diff --git a/main/tests/test_io.h b/main/tests/test_astar.h
index 76567829e7..0b3e4d6c9d 100644
--- a/main/tests/test_io.h
+++ b/main/tests/test_astar.h
@@ -1,12 +1,12 @@
/*************************************************************************/
-/* test_io.h */
+/* test_astar.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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,16 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef TEST_IO_H
-#define TEST_IO_H
+#ifndef TEST_ASTAR_H
+#define TEST_ASTAR_H
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
+#include "core/os/main_loop.h"
-#include "os/main_loop.h"
-
-namespace TestIO {
+namespace TestAStar {
MainLoop *test();
}
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp
index 0a9d03c1b7..55e31a18c3 100644
--- a/main/tests/test_gdscript.cpp
+++ b/main/tests/test_gdscript.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -30,9 +30,9 @@
#include "test_gdscript.h"
-#include "os/file_access.h"
-#include "os/main_loop.h"
-#include "os/os.h"
+#include "core/os/file_access.h"
+#include "core/os/main_loop.h"
+#include "core/os/os.h"
#ifdef GDSCRIPT_ENABLED
@@ -357,8 +357,8 @@ static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_i
_parser_show_block(cf_node->body, p_indent + 1);
} break;
- case GDScriptParser::ControlFlowNode::CF_SWITCH: {
-
+ case GDScriptParser::ControlFlowNode::CF_MATCH: {
+ // FIXME: Implement
} break;
case GDScriptParser::ControlFlowNode::CF_CONTINUE: {
@@ -908,11 +908,14 @@ MainLoop *test(TestType p_type) {
List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
if (cmdlargs.empty()) {
- //try editor!
return NULL;
}
String test = cmdlargs.back()->get();
+ if (!test.ends_with(".gd") && !test.ends_with(".gdc")) {
+ print_line("This test expects a path to a GDScript file as its last parameter. Got: " + test);
+ return NULL;
+ }
FileAccess *fa = FileAccess::open(test, FileAccess::READ);
@@ -1038,10 +1041,10 @@ MainLoop *test(TestType p_type) {
} else if (p_type == TEST_BYTECODE) {
- Vector<uint8_t> buf = GDScriptTokenizerBuffer::parse_code_string(code);
+ Vector<uint8_t> buf2 = GDScriptTokenizerBuffer::parse_code_string(code);
String dst = test.get_basename() + ".gdc";
FileAccess *fw = FileAccess::open(dst, FileAccess::WRITE);
- fw->store_buffer(buf.ptr(), buf.size());
+ fw->store_buffer(buf2.ptr(), buf2.size());
memdelete(fw);
}
diff --git a/main/tests/test_gdscript.h b/main/tests/test_gdscript.h
index 91e0be1238..6b98f7cc41 100644
--- a/main/tests/test_gdscript.h
+++ b/main/tests/test_gdscript.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -31,7 +31,7 @@
#ifndef TEST_GDSCRIPT_H
#define TEST_GDSCRIPT_H
-#include "os/main_loop.h"
+#include "core/os/main_loop.h"
namespace TestGDScript {
diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp
index 305b749717..a71b9cdc69 100644
--- a/main/tests/test_gui.cpp
+++ b/main/tests/test_gui.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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,9 +32,9 @@
#include "test_gui.h"
-#include "io/image_loader.h"
-#include "os/os.h"
-#include "print_string.h"
+#include "core/io/image_loader.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
#include "scene/2d/sprite.h"
#include "scene/gui/button.h"
#include "scene/gui/control.h"
@@ -60,8 +60,6 @@ namespace TestGUI {
class TestMainLoop : public SceneTree {
- Control *control;
-
public:
virtual void request_quit() {
@@ -235,7 +233,7 @@ public:
richtext->push_meta("http://www.scrollingcapabilities.xz");
richtext->add_text("This allows to test for the scrolling capabilities ");
richtext->pop();
- richtext->add_text("of the rich text label for huge text (not like this text will really be huge but, you know).\nAs long as it is so long that it will work nicely for a test/demo, then it's welcomed in my book...\nChanging subject, the day is cloudy today and I'm wondering if I'll get che chance to travel somewhere nice. Sometimes, watching the clouds from satellite images may give a nice insight about how pressure zones in our planet work, althogh it also makes it pretty obvious to see why most weather forecasts get it wrong so often.\nClouds are so difficult to predict!\nBut it's pretty cool how our civilization has adapted to having water falling from the sky each time it rains...");
+ richtext->add_text("of the rich text label for huge text (not like this text will really be huge but, you know).\nAs long as it is so long that it will work nicely for a test/demo, then it's welcomed in my book...\nChanging subject, the day is cloudy today and I'm wondering if I'll get che chance to travel somewhere nice. Sometimes, watching the clouds from satellite images may give a nice insight about how pressure zones in our planet work, although it also makes it pretty obvious to see why most weather forecasts get it wrong so often.\nClouds are so difficult to predict!\nBut it's pretty cool how our civilization has adapted to having water falling from the sky each time it rains...");
TabContainer *tabc = memnew(TabContainer);
diff --git a/main/tests/test_gui.h b/main/tests/test_gui.h
index 3ed9dae522..1752818981 100644
--- a/main/tests/test_gui.h
+++ b/main/tests/test_gui.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -31,7 +31,7 @@
#ifndef TEST_GUI_H
#define TEST_GUI_H
-#include "os/main_loop.h"
+#include "core/os/main_loop.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/main/tests/test_image.h b/main/tests/test_image.h
deleted file mode 100644
index d45b4e4e15..0000000000
--- a/main/tests/test_image.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*************************************************************************/
-/* test_image.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 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_IMAGE_H
-#define TEST_IMAGE_H
-
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-
-#include "os/main_loop.h"
-
-namespace TestImage {
-
-MainLoop *test();
-}
-
-#endif
diff --git a/main/tests/test_io.cpp b/main/tests/test_io.cpp
deleted file mode 100644
index 4f98955995..0000000000
--- a/main/tests/test_io.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*************************************************************************/
-/* test_io.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 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_io.h"
-
-#ifdef MINIZIP_ENABLED
-
-#include "core/project_settings.h"
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-#include "os/dir_access.h"
-#include "os/main_loop.h"
-#include "os/os.h"
-#include "print_string.h"
-#include "scene/resources/texture.h"
-
-#include "io/file_access_memory.h"
-
-namespace TestIO {
-
-class TestMainLoop : public MainLoop {
-
- bool quit;
-
-public:
- virtual void input_event(const InputEvent &p_event) {
- }
- virtual bool idle(float p_time) {
- return false;
- }
-
- virtual void request_quit() {
-
- quit = true;
- }
- virtual void init() {
-
- quit = true;
- }
- virtual bool iteration(float p_time) {
-
- return quit;
- }
- virtual void finish() {
- }
-};
-
-MainLoop *test() {
-
- print_line("this is test io");
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- da->change_dir(".");
- print_line("Opening current dir " + da->get_current_dir());
- String entry;
- da->list_dir_begin();
- while ((entry = da->get_next()) != "") {
-
- print_line("entry " + entry + " is dir: " + Variant(da->current_is_dir()));
- };
- da->list_dir_end();
-
- RES texture = ResourceLoader::load("test_data/rock.png");
- ERR_FAIL_COND_V(texture.is_null(), NULL);
-
- ResourceSaver::save("test_data/rock.xml", texture);
-
- print_line("localize paths");
- print_line(ProjectSettings::get_singleton()->localize_path("algo.xml"));
- print_line(ProjectSettings::get_singleton()->localize_path("c:\\windows\\algo.xml"));
- print_line(ProjectSettings::get_singleton()->localize_path(ProjectSettings::get_singleton()->get_resource_path() + "/something/something.xml"));
- print_line(ProjectSettings::get_singleton()->localize_path("somedir/algo.xml"));
-
- {
-
- FileAccess *z = FileAccess::open("test_data/archive.zip", FileAccess::READ);
- int len = z->get_len();
- Vector<uint8_t> zip;
- zip.resize(len);
- z->get_buffer(zip.ptrw(), len);
- z->close();
- memdelete(z);
-
- FileAccessMemory::register_file("a_package", zip);
- FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_RESOURCES);
- FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_FILESYSTEM);
- FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_USERDATA);
-
- print_line("archive test");
- };
-
- print_line("test done");
-
- return memnew(TestMainLoop);
-}
-} // namespace TestIO
-
-#else
-
-namespace TestIO {
-
-MainLoop *test() {
-
- return NULL;
-}
-} // namespace TestIO
-#endif
diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp
index cbc1107acb..22f1d7319f 100644
--- a/main/tests/test_main.cpp
+++ b/main/tests/test_main.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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,15 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "list.h"
-#include "os/main_loop.h"
+#include "core/list.h"
+#include "core/os/main_loop.h"
#ifdef DEBUG_ENABLED
+#include "test_astar.h"
#include "test_gdscript.h"
#include "test_gui.h"
-#include "test_image.h"
-#include "test_io.h"
#include "test_math.h"
#include "test_oa_hash_map.h"
#include "test_ordered_hash_map.h"
@@ -56,14 +55,13 @@ const char **tests_get_names() {
"render",
"oa_hash_map",
"gui",
- "io",
"shaderlang",
"gd_tokenizer",
"gd_parser",
"gd_compiler",
"gd_bytecode",
- "image",
"ordered_hash_map",
+ "astar",
NULL
};
@@ -109,11 +107,6 @@ MainLoop *test_main(String p_test, const List<String> &p_args) {
}
#endif
- if (p_test == "io") {
-
- return TestIO::test();
- }
-
if (p_test == "shaderlang") {
return TestShaderLang::test();
@@ -139,16 +132,17 @@ MainLoop *test_main(String p_test, const List<String> &p_args) {
return TestGDScript::test(TestGDScript::TEST_BYTECODE);
}
- if (p_test == "image") {
+ if (p_test == "ordered_hash_map") {
- return TestImage::test();
+ return TestOrderedHashMap::test();
}
- if (p_test == "ordered_hash_map") {
+ if (p_test == "astar") {
- return TestOrderedHashMap::test();
+ return TestAStar::test();
}
+ print_line("Unknown test: " + p_test);
return NULL;
}
diff --git a/main/tests/test_main.h b/main/tests/test_main.h
index d319391070..521284bec8 100644
--- a/main/tests/test_main.h
+++ b/main/tests/test_main.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -31,8 +31,8 @@
#ifndef TEST_MAIN_H
#define TEST_MAIN_H
-#include "list.h"
-#include "ustring.h"
+#include "core/list.h"
+#include "core/ustring.h"
const char **tests_get_names();
MainLoop *test_main(String p_test, const List<String> &p_args);
diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp
index 1a72416d6a..f341159079 100644
--- a/main/tests/test_math.cpp
+++ b/main/tests/test_math.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -30,22 +30,22 @@
#include "test_math.h"
-#include "camera_matrix.h"
-#include "math_funcs.h"
-#include "matrix3.h"
-#include "os/file_access.h"
-#include "os/keyboard.h"
-#include "os/os.h"
-#include "print_string.h"
+#include "core/math/basis.h"
+#include "core/math/camera_matrix.h"
+#include "core/math/math_funcs.h"
+#include "core/math/transform.h"
+#include "core/os/file_access.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
+#include "core/ustring.h"
+#include "core/variant.h"
+#include "core/vmap.h"
#include "scene/main/node.h"
#include "scene/resources/texture.h"
#include "servers/visual/shader_language.h"
-#include "transform.h"
-#include "ustring.h"
-#include "variant.h"
-#include "vmap.h"
-#include "method_ptrcall.h"
+#include "core/method_ptrcall.h"
namespace TestMath {
@@ -444,14 +444,11 @@ MainLoop *test() {
float bb = (rgbe >> 18) & 0x1ff;
float eb = (rgbe >> 27);
float mb = Math::pow(2, eb - 15.0 - 9.0);
- ;
float rd = rb * mb;
float gd = gb * mb;
float bd = bb * mb;
print_line("RGBE: " + Color(rd, gd, bd));
-
- return NULL;
}
print_line("Dvectors: " + itos(MemoryPool::allocs_used));
@@ -482,8 +479,6 @@ MainLoop *test() {
print_line("later Mem used: " + itos(MemoryPool::total_memory));
print_line("Mlater Ax mem used: " + itos(MemoryPool::max_memory));
- return NULL;
-
List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
if (cmdlargs.empty()) {
@@ -492,6 +487,11 @@ MainLoop *test() {
}
String test = cmdlargs.back()->get();
+ if (test == "math") {
+ // Not a file name but the test name, abort.
+ // FIXME: This test is ugly as heck, needs fixing :)
+ return NULL;
+ }
FileAccess *fa = FileAccess::open(test, FileAccess::READ);
@@ -516,8 +516,6 @@ MainLoop *test() {
print_line("Found class: " + getclass.get_class());
}
- return NULL;
-
{
Vector<int> hashes;
@@ -557,13 +555,10 @@ MainLoop *test() {
}
print_line("DONE");
-
- return NULL;
}
- {
+ {
print_line("NUM: " + itos(-128));
- return NULL;
}
{
@@ -593,7 +588,6 @@ MainLoop *test() {
print_line("after v: " + v + " a: " + rtos(a));
}
- return NULL;
String ret;
List<String> args;
@@ -602,7 +596,6 @@ MainLoop *test() {
print_line("error: " + itos(err));
print_line(ret);
- return NULL;
Basis m3;
m3.rotate(Vector3(1, 0, 0), 0.2);
m3.rotate(Vector3(0, 1, 0), 1.77);
@@ -611,17 +604,13 @@ MainLoop *test() {
m32.set_euler(m3.get_euler());
print_line("ELEULEEEEEEEEEEEEEEEEEER: " + m3.get_euler() + " vs " + m32.get_euler());
- return NULL;
-
{
-
Dictionary d;
d["momo"] = 1;
Dictionary b = d;
b["44"] = 4;
}
- return NULL;
print_line("inters: " + rtos(Geometry::segment_intersects_circle(Vector2(-5, 0), Vector2(-2, 0), Vector2(), 1.0)));
print_line("cross: " + Vector3(1, 2, 3).cross(Vector3(4, 5, 7)));
diff --git a/main/tests/test_math.h b/main/tests/test_math.h
index 26a33aa164..9f1e96358f 100644
--- a/main/tests/test_math.h
+++ b/main/tests/test_math.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -31,7 +31,7 @@
#ifndef TEST_MATH_H
#define TEST_MATH_H
-#include "os/main_loop.h"
+#include "core/os/main_loop.h"
namespace TestMath {
diff --git a/main/tests/test_oa_hash_map.cpp b/main/tests/test_oa_hash_map.cpp
index 0e34faace7..070420e432 100644
--- a/main/tests/test_oa_hash_map.cpp
+++ b/main/tests/test_oa_hash_map.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -48,7 +48,7 @@ MainLoop *test() {
map.set(1337, 21);
map.set(42, 11880);
- int value;
+ int value = 0;
map.lookup(42, value);
OS::get_singleton()->print("capacity %d\n", map.get_capacity());
@@ -92,6 +92,35 @@ MainLoop *test() {
}
}
+ // stress test / test for issue #22928
+ {
+ OAHashMap<int, int> map;
+ int dummy = 0;
+ const int N = 1000;
+ uint32_t *keys = new uint32_t[N];
+
+ Math::seed(0);
+
+ // insert a couple of random keys (with a dummy value, which is ignored)
+ for (int i = 0; i < N; i++) {
+ keys[i] = Math::rand();
+ map.set(keys[i], dummy);
+
+ if (!map.lookup(keys[i], dummy))
+ OS::get_singleton()->print("could not find 0x%X despite it was just inserted!\n", unsigned(keys[i]));
+ }
+
+ // check whether the keys are still present
+ for (int i = 0; i < N; i++) {
+ if (!map.lookup(keys[i], dummy)) {
+ OS::get_singleton()->print("could not find 0x%X despite it has been inserted previously! (not checking the other keys, breaking...)\n", unsigned(keys[i]));
+ break;
+ }
+ }
+
+ delete[] keys;
+ }
+
return NULL;
}
} // namespace TestOAHashMap
diff --git a/main/tests/test_oa_hash_map.h b/main/tests/test_oa_hash_map.h
index a63da537d8..fb43dc325f 100644
--- a/main/tests/test_oa_hash_map.h
+++ b/main/tests/test_oa_hash_map.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -31,7 +31,7 @@
#ifndef TEST_OA_HASH_MAP_H
#define TEST_OA_HASH_MAP_H
-#include "os/main_loop.h"
+#include "core/os/main_loop.h"
namespace TestOAHashMap {
diff --git a/main/tests/test_ordered_hash_map.cpp b/main/tests/test_ordered_hash_map.cpp
index 668a8788ff..6aef94efe3 100644
--- a/main/tests/test_ordered_hash_map.cpp
+++ b/main/tests/test_ordered_hash_map.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "ordered_hash_map.h"
-#include "os/os.h"
-#include "pair.h"
-#include "vector.h"
+#include "core/ordered_hash_map.h"
+#include "core/os/os.h"
+#include "core/pair.h"
+#include "core/vector.h"
namespace TestOrderedHashMap {
@@ -168,4 +168,4 @@ MainLoop *test() {
return NULL;
}
-} // namespace TestOrderedHashMap \ No newline at end of file
+} // namespace TestOrderedHashMap
diff --git a/main/tests/test_ordered_hash_map.h b/main/tests/test_ordered_hash_map.h
index 6723e70b79..731a36a716 100644
--- a/main/tests/test_ordered_hash_map.h
+++ b/main/tests/test_ordered_hash_map.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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/main/tests/test_physics.cpp b/main/tests/test_physics.cpp
index 99c8fce70e..84f504a78d 100644
--- a/main/tests/test_physics.cpp
+++ b/main/tests/test_physics.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -30,12 +30,12 @@
#include "test_physics.h"
-#include "map.h"
-#include "math_funcs.h"
-#include "os/main_loop.h"
-#include "os/os.h"
-#include "print_string.h"
-#include "quick_hull.h"
+#include "core/map.h"
+#include "core/math/math_funcs.h"
+#include "core/math/quick_hull.h"
+#include "core/os/main_loop.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
#include "servers/physics_server.h"
#include "servers/visual_server.h"
diff --git a/main/tests/test_physics.h b/main/tests/test_physics.h
index 4d62f3a0cf..699e31f492 100644
--- a/main/tests/test_physics.h
+++ b/main/tests/test_physics.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -35,7 +35,7 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-#include "os/main_loop.h"
+#include "core/os/main_loop.h"
namespace TestPhysics {
diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp
index 482a858650..9a2bf0107a 100644
--- a/main/tests/test_physics_2d.cpp
+++ b/main/tests/test_physics_2d.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -30,10 +30,10 @@
#include "test_physics_2d.h"
-#include "map.h"
-#include "os/main_loop.h"
-#include "os/os.h"
-#include "print_string.h"
+#include "core/map.h"
+#include "core/os/main_loop.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
#include "scene/resources/texture.h"
#include "servers/physics_2d_server.h"
#include "servers/visual_server.h"
diff --git a/main/tests/test_physics_2d.h b/main/tests/test_physics_2d.h
index 1031aa7f71..3a513f4d6e 100644
--- a/main/tests/test_physics_2d.h
+++ b/main/tests/test_physics_2d.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -31,7 +31,7 @@
#ifndef TEST_PHYSICS_2D_H
#define TEST_PHYSICS_2D_H
-#include "os/main_loop.h"
+#include "core/os/main_loop.h"
namespace TestPhysics2D {
diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp
index 9340e69bc5..826d544f13 100644
--- a/main/tests/test_render.cpp
+++ b/main/tests/test_render.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -30,12 +30,12 @@
#include "test_render.h"
-#include "math_funcs.h"
-#include "os/keyboard.h"
-#include "os/main_loop.h"
-#include "os/os.h"
-#include "print_string.h"
-#include "quick_hull.h"
+#include "core/math/math_funcs.h"
+#include "core/math/quick_hull.h"
+#include "core/os/keyboard.h"
+#include "core/os/main_loop.h"
+#include "core/os/os.h"
+#include "core/print_string.h"
#include "servers/visual_server.h"
#define OBJECT_COUNT 50
diff --git a/main/tests/test_render.h b/main/tests/test_render.h
index 9084b57067..3810760b56 100644
--- a/main/tests/test_render.h
+++ b/main/tests/test_render.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -35,7 +35,7 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-#include "os/main_loop.h"
+#include "core/os/main_loop.h"
namespace TestRender {
diff --git a/main/tests/test_shader_lang.cpp b/main/tests/test_shader_lang.cpp
index 7103b436e1..dcb19b7df7 100644
--- a/main/tests/test_shader_lang.cpp
+++ b/main/tests/test_shader_lang.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -30,11 +30,11 @@
#include "test_shader_lang.h"
-#include "os/file_access.h"
-#include "os/main_loop.h"
-#include "os/os.h"
+#include "core/os/file_access.h"
+#include "core/os/main_loop.h"
+#include "core/os/os.h"
-#include "print_string.h"
+#include "core/print_string.h"
#include "scene/gui/control.h"
#include "scene/gui/text_edit.h"
#include "servers/visual/shader_language.h"
@@ -110,7 +110,7 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) {
String ucode = "uniform ";
- ucode += _prestr(E->get().precission);
+ ucode += _prestr(E->get().precision);
ucode += _typestr(E->get().type);
ucode += " " + String(E->key());
@@ -137,7 +137,7 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) {
String vcode = "varying ";
- vcode += _prestr(E->get().precission);
+ vcode += _prestr(E->get().precision);
vcode += _typestr(E->get().type);
vcode += " " + String(E->key());
@@ -149,11 +149,11 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
String header;
header = _typestr(fnode->return_type) + " " + fnode->name + "(";
- for (int i = 0; i < fnode->arguments.size(); i++) {
+ for (int j = 0; j < fnode->arguments.size(); j++) {
- if (i > 0)
+ if (j > 0)
header += ", ";
- header += _prestr(fnode->arguments[i].precision) + _typestr(fnode->arguments[i].type) + " " + fnode->arguments[i].name;
+ header += _prestr(fnode->arguments[j].precision) + _typestr(fnode->arguments[j].type) + " " + fnode->arguments[j].name;
}
header += ")\n";
@@ -180,7 +180,7 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
String scode = dump_node_code(bnode->statements[i], p_level);
- if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW || bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW) {
+ if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW) {
code += scode; //use directly
} else {
code += _mktab(p_level) + scode + ";\n";
@@ -194,6 +194,9 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
code = vnode->name;
} break;
+ case SL::Node::TYPE_VARIABLE_DECLARATION: {
+ // FIXME: Implement
+ } break;
case SL::Node::TYPE_CONSTANT: {
SL::ConstantNode *cnode = (SL::ConstantNode *)p_node;
return get_constant_text(cnode->datatype, cnode->values);
@@ -333,9 +336,9 @@ MainLoop *test() {
print_line("Error at line: " + rtos(sl.get_error_line()) + ": " + sl.get_error_text());
return NULL;
} else {
- String code;
- recreate_code(&code, sl.get_shader());
- print_line("code:\n\n" + code);
+ String code2;
+ recreate_code(&code2, sl.get_shader());
+ print_line("code:\n\n" + code2);
}
return NULL;
diff --git a/main/tests/test_shader_lang.h b/main/tests/test_shader_lang.h
index 235bf10463..79213aa96f 100644
--- a/main/tests/test_shader_lang.h
+++ b/main/tests/test_shader_lang.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -31,7 +31,7 @@
#ifndef TEST_SHADER_LANG_H
#define TEST_SHADER_LANG_H
-#include "os/main_loop.h"
+#include "core/os/main_loop.h"
namespace TestShaderLang {
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index af948556c4..3465fd783e 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "ustring.h"
+#include "core/ustring.h"
#include <wchar.h>
-//#include "math_funcs.h"
+//#include "core/math/math_funcs.h"
#include "core/io/ip_address.h"
-#include "os/os.h"
+#include "core/os/os.h"
#include <stdio.h>
#include "test_string.h"
@@ -457,7 +457,7 @@ bool test_27() {
state = s.begins_with(sb) == tc[i].expected;
}
if (!state) {
- OS::get_singleton()->print("\n\t Failure on:\n\t\tstring: ", tc[i].data, "\n\t\tbegin: ", tc[i].begin, "\n\t\texpected: ", tc[i].expected ? "true" : "false", "\n");
+ OS::get_singleton()->print("\n\t Failure on:\n\t\tstring: %s\n\t\tbegin: %s\n\t\texpected: %s\n", tc[i].data, tc[i].begin, tc[i].expected ? "true" : "false");
break;
}
};
@@ -480,7 +480,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish % frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
//////// INTS
@@ -491,7 +491,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int left padded with zeroes.
format = "fish %05d frog";
@@ -500,7 +500,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 00005 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int left padded with spaces.
format = "fish %5d frog";
@@ -509,7 +509,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int right padded with spaces.
format = "fish %-5d frog";
@@ -518,7 +518,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int with sign (positive).
format = "fish %+d frog";
@@ -527,7 +527,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish +5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Negative int.
format = "fish %d frog";
@@ -536,7 +536,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish -5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Hex (lower)
format = "fish %x frog";
@@ -545,7 +545,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 2d frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Hex (upper)
format = "fish %X frog";
@@ -554,7 +554,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 2D frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Octal
format = "fish %o frog";
@@ -563,7 +563,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 143 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
////// REALS
@@ -574,7 +574,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real left-padded
format = "fish %11f frog";
@@ -583,7 +583,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real right-padded
format = "fish %-11f frog";
@@ -592,7 +592,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real given int.
format = "fish %f frog";
@@ -601,7 +601,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.000000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real with sign (positive).
format = "fish %+f frog";
@@ -610,7 +610,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish +99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real with 1 decimals.
format = "fish %.1f frog";
@@ -619,7 +619,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 100.0 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real with 12 decimals.
format = "fish %.12f frog";
@@ -628,7 +628,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000000000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Real with no decimals.
format = "fish %.f frog";
@@ -637,7 +637,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 100 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
/////// Strings.
@@ -648,7 +648,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// String left-padded
format = "fish %10s frog";
@@ -657,7 +657,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// String right-padded
format = "fish %-10s frog";
@@ -666,7 +666,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
///// Characters
@@ -677,7 +677,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish A frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Character as int.
format = "fish %c frog";
@@ -686,7 +686,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish A frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
///// Dynamic width
@@ -698,7 +698,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Int dynamic width
format = "fish %*d frog";
@@ -708,7 +708,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Float dynamic width
format = "fish %*.*f frog";
@@ -719,7 +719,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == String("fish 99.990 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
///// Errors
@@ -730,7 +730,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "not enough arguments for format string" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// More arguments than formats.
format = "fish %s frog";
@@ -740,7 +740,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "not all arguments converted during string formatting" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Incomplete format.
format = "fish %10";
@@ -749,7 +749,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "incomplete format" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Bad character in format string
format = "fish %&f frog";
@@ -758,7 +758,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "unsupported format character" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Too many decimals.
format = "fish %2.2.2f frog";
@@ -767,7 +767,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "too many decimal points in format" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// * not a number
format = "fish %*f frog";
@@ -777,7 +777,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "* wants number" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Character too long.
format = "fish %c frog";
@@ -786,7 +786,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "%c requires number or single-character string" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
// Character bad type.
format = "fish %c frog";
@@ -795,7 +795,7 @@ bool test_28() {
output = format.sprintf(args, &error);
success = (output == "%c requires number or single-character string" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
return state;
}
@@ -819,41 +819,240 @@ bool test_29() {
String ip4 = "192.168.0.1";
bool success = ip4.is_valid_ip_address();
OS::get_singleton()->print("Is valid ipv4: %ls, %s\n", ip4.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip4 = "192.368.0.1";
success = (!ip4.is_valid_ip_address());
OS::get_singleton()->print("Is invalid ipv4: %ls, %s\n", ip4.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
String ip6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
success = ip6.is_valid_ip_address();
OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip6 = "2001:0db8:85j3:0000:0000:8a2e:0370:7334";
success = (!ip6.is_valid_ip_address());
OS::get_singleton()->print("Is invalid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip6 = "2001:0db8:85f345:0000:0000:8a2e:0370:7334";
success = (!ip6.is_valid_ip_address());
OS::get_singleton()->print("Is invalid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip6 = "2001:0db8::0:8a2e:370:7334";
success = (ip6.is_valid_ip_address());
OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
- if (!success) state = false;
+ state = state && success;
ip6 = "::ffff:192.168.0.1";
success = (ip6.is_valid_ip_address());
OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL");
+ state = state && success;
+
+ return state;
+};
+
+bool test_30() {
+ bool state = true;
+ bool success = true;
+ String input = "bytes2var";
+ String output = "Bytes 2 Var";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "linear2db";
+ output = "Linear 2 Db";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "vector3";
+ output = "Vector 3";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "sha256";
+ output = "Sha 256";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "2db";
+ output = "2 Db";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "PascalCase";
+ output = "Pascal Case";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "PascalPascalCase";
+ output = "Pascal Pascal Case";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "snake_case";
+ output = "Snake Case";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "snake_snake_case";
+ output = "Snake Snake Case";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "sha256sum";
+ output = "Sha 256 Sum";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "cat2dog";
+ output = "Cat 2 Dog";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "function(name)";
+ output = "Function(name)";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls (existing incorrect behavior): %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "snake_case_function(snake_case_arg)";
+ output = "Snake Case Function(snake Case Arg)";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls (existing incorrect behavior): %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ input = "snake_case_function( snake_case_arg )";
+ output = "Snake Case Function( Snake Case Arg )";
+ success = (input.capitalize() == output);
+ state = state && success;
+ OS::get_singleton()->print("Capitalize %ls: %ls, %s\n", input.c_str(), output.c_str(), success ? "OK" : "FAIL");
+
+ return state;
+}
+
+bool test_31() {
+ bool state = true;
+ bool success;
+
+ String a = "";
+ success = a[0] == 0;
+ OS::get_singleton()->print("Is 0 String[0]:, %s\n", success ? "OK" : "FAIL");
+ if (!success) state = false;
+
+ String b = "Godot";
+ success = b[b.size()] == 0;
+ OS::get_singleton()->print("Is 0 String[size()]:, %s\n", success ? "OK" : "FAIL");
+ if (!success) state = false;
+
+ const String c = "";
+ success = c[0] == 0;
+ OS::get_singleton()->print("Is 0 const String[0]:, %s\n", success ? "OK" : "FAIL");
+ if (!success) state = false;
+
+ const String d = "Godot";
+ success = d[d.size()] == 0;
+ OS::get_singleton()->print("Is 0 const String[size()]:, %s\n", success ? "OK" : "FAIL");
if (!success) state = false;
return state;
};
+bool test_32() {
+
+#define STRIP_TEST(x) \
+ { \
+ bool success = x; \
+ state = state && success; \
+ if (!success) { \
+ OS::get_singleton()->print("\tfailed at: %s\n", #x); \
+ } \
+ }
+
+ OS::get_singleton()->print("\n\nTest 32: lstrip and rstrip\n");
+ bool state = true;
+
+ // strip none
+ STRIP_TEST(String("abc").lstrip("") == "abc");
+ STRIP_TEST(String("abc").rstrip("") == "abc");
+ // strip one
+ STRIP_TEST(String("abc").lstrip("a") == "bc");
+ STRIP_TEST(String("abc").rstrip("c") == "ab");
+ // strip lots
+ STRIP_TEST(String("bababbababccc").lstrip("ab") == "ccc");
+ STRIP_TEST(String("aaabcbcbcbbcbbc").rstrip("cb") == "aaa");
+ // strip empty string
+ STRIP_TEST(String("").lstrip("") == "");
+ STRIP_TEST(String("").rstrip("") == "");
+ // strip to empty string
+ STRIP_TEST(String("abcabcabc").lstrip("bca") == "");
+ STRIP_TEST(String("abcabcabc").rstrip("bca") == "");
+ // don't strip wrong end
+ STRIP_TEST(String("abc").lstrip("c") == "abc");
+ STRIP_TEST(String("abca").lstrip("a") == "bca");
+ STRIP_TEST(String("abc").rstrip("a") == "abc");
+ STRIP_TEST(String("abca").rstrip("a") == "abc");
+ // in utf-8 "¿" has the same first byte as "µ"
+ // and the same second as "ÿ"
+ STRIP_TEST(String::utf8("¿").lstrip(String::utf8("µÿ")) == String::utf8("¿"));
+ STRIP_TEST(String::utf8("¿").rstrip(String::utf8("µÿ")) == String::utf8("¿"));
+ STRIP_TEST(String::utf8("µ¿ÿ").lstrip(String::utf8("µÿ")) == String::utf8("¿ÿ"));
+ STRIP_TEST(String::utf8("µ¿ÿ").rstrip(String::utf8("µÿ")) == String::utf8("µ¿"));
+
+ // the above tests repeated with additional superfluous strip chars
+
+ // strip none
+ STRIP_TEST(String("abc").lstrip("qwjkl") == "abc");
+ STRIP_TEST(String("abc").rstrip("qwjkl") == "abc");
+ // strip one
+ STRIP_TEST(String("abc").lstrip("qwajkl") == "bc");
+ STRIP_TEST(String("abc").rstrip("qwcjkl") == "ab");
+ // strip lots
+ STRIP_TEST(String("bababbababccc").lstrip("qwabjkl") == "ccc");
+ STRIP_TEST(String("aaabcbcbcbbcbbc").rstrip("qwcbjkl") == "aaa");
+ // strip empty string
+ STRIP_TEST(String("").lstrip("qwjkl") == "");
+ STRIP_TEST(String("").rstrip("qwjkl") == "");
+ // strip to empty string
+ STRIP_TEST(String("abcabcabc").lstrip("qwbcajkl") == "");
+ STRIP_TEST(String("abcabcabc").rstrip("qwbcajkl") == "");
+ // don't strip wrong end
+ STRIP_TEST(String("abc").lstrip("qwcjkl") == "abc");
+ STRIP_TEST(String("abca").lstrip("qwajkl") == "bca");
+ STRIP_TEST(String("abc").rstrip("qwajkl") == "abc");
+ STRIP_TEST(String("abca").rstrip("qwajkl") == "abc");
+ // in utf-8 "¿" has the same first byte as "µ"
+ // and the same second as "ÿ"
+ STRIP_TEST(String::utf8("¿").lstrip(String::utf8("qwaµÿjkl")) == String::utf8("¿"));
+ STRIP_TEST(String::utf8("¿").rstrip(String::utf8("qwaµÿjkl")) == String::utf8("¿"));
+ STRIP_TEST(String::utf8("µ¿ÿ").lstrip(String::utf8("qwaµÿjkl")) == String::utf8("¿ÿ"));
+ STRIP_TEST(String::utf8("µ¿ÿ").rstrip(String::utf8("qwaµÿjkl")) == String::utf8("µ¿"));
+
+ return state;
+
+#undef STRIP_TEST
+}
+
+bool test_33() {
+ OS::get_singleton()->print("\n\nTest 33: parse_utf8(null, -1)\n");
+
+ String empty;
+ return empty.parse_utf8(NULL, -1) == true;
+}
+
typedef bool (*TestFunc)(void);
TestFunc test_funcs[] = {
@@ -887,6 +1086,10 @@ TestFunc test_funcs[] = {
test_27,
test_28,
test_29,
+ test_30,
+ test_31,
+ test_32,
+ test_33,
0
};
diff --git a/main/tests/test_string.h b/main/tests/test_string.h
index 110e115309..a8adb3a890 100644
--- a/main/tests/test_string.h
+++ b/main/tests/test_string.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -31,8 +31,8 @@
#ifndef TEST_STRING_H
#define TEST_STRING_H
-#include "os/main_loop.h"
-#include "ustring.h"
+#include "core/os/main_loop.h"
+#include "core/ustring.h"
namespace TestString {