diff options
-rw-r--r-- | doc/classes/HSlider.xml | 1 | ||||
-rw-r--r-- | doc/classes/Slider.xml | 1 | ||||
-rw-r--r-- | doc/classes/VSlider.xml | 1 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 2 | ||||
-rw-r--r-- | scene/gui/spin_box.cpp | 2 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 2 | ||||
-rw-r--r-- | tests/test_ordered_hash_map.cpp | 175 | ||||
-rw-r--r-- | tests/test_ordered_hash_map.h | 102 |
8 files changed, 106 insertions, 180 deletions
diff --git a/doc/classes/HSlider.xml b/doc/classes/HSlider.xml index afe9d10d2e..0cbb4fd455 100644 --- a/doc/classes/HSlider.xml +++ b/doc/classes/HSlider.xml @@ -5,6 +5,7 @@ </brief_description> <description> Horizontal slider. See [Slider]. This one goes from left (min) to right (max). + [b]Note:[/b] The [signal Range.changed] and [signal Range.value_changed] signals are part of the [Range] class which this class inherits from. </description> <tutorials> </tutorials> diff --git a/doc/classes/Slider.xml b/doc/classes/Slider.xml index 68776df603..f18b2ce39f 100644 --- a/doc/classes/Slider.xml +++ b/doc/classes/Slider.xml @@ -5,6 +5,7 @@ </brief_description> <description> Base class for GUI sliders. + [b]Note:[/b] The [signal Range.changed] and [signal Range.value_changed] signals are part of the [Range] class which this class inherits from. </description> <tutorials> </tutorials> diff --git a/doc/classes/VSlider.xml b/doc/classes/VSlider.xml index 9394d6b430..5830c9eaf3 100644 --- a/doc/classes/VSlider.xml +++ b/doc/classes/VSlider.xml @@ -5,6 +5,7 @@ </brief_description> <description> Vertical slider. See [Slider]. This one goes from bottom (min) to top (max). + [b]Note:[/b] The [signal Range.changed] and [signal Range.value_changed] signals are part of the [Range] class which this class inherits from. </description> <tutorials> </tutorials> diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 5afc1f438e..14167531a5 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -578,7 +578,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { if (handled) { accept_event(); - } else if (!k->get_command()) { + } else if (!k->get_command() || (k->get_command() && k->get_alt())) { if (k->get_unicode() >= 32 && k->get_keycode() != KEY_DELETE) { if (editable) { selection_delete(); diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 3670f13705..ae2f99e91d 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -62,8 +62,8 @@ void SpinBox::_text_entered(const String &p_string) { Variant value = expr->execute(Array(), nullptr, false); if (value.get_type() != Variant::NIL) { set_value(value); - _value_changed(0); } + _value_changed(0); } LineEdit *SpinBox::get_line_edit() { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index e17085cafc..a17fdd0651 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3604,7 +3604,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (!keycode_handled && !k->get_command()) { // For German keyboards. + if (!keycode_handled && (!k->get_command() || (k->get_command() && k->get_alt()))) { // For German keyboards. if (k->get_unicode() >= 32) { if (readonly) { diff --git a/tests/test_ordered_hash_map.cpp b/tests/test_ordered_hash_map.cpp deleted file mode 100644 index d18a3784be..0000000000 --- a/tests/test_ordered_hash_map.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/*************************************************************************/ -/* test_ordered_hash_map.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 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_ordered_hash_map.h" - -#include "core/ordered_hash_map.h" -#include "core/os/os.h" -#include "core/pair.h" -#include "core/vector.h" - -namespace TestOrderedHashMap { - -bool test_insert() { - OrderedHashMap<int, int> map; - OrderedHashMap<int, int>::Element e = map.insert(42, 84); - - return e && e.key() == 42 && e.get() == 84 && e.value() == 84 && map[42] == 84 && map.has(42) && map.find(42); -} - -bool test_insert_overwrite() { - OrderedHashMap<int, int> map; - map.insert(42, 84); - map.insert(42, 1234); - - return map[42] == 1234; -} - -bool test_erase_via_element() { - OrderedHashMap<int, int> map; - OrderedHashMap<int, int>::Element e = map.insert(42, 84); - - map.erase(e); - return !e && !map.has(42) && !map.find(42); -} - -bool test_erase_via_key() { - OrderedHashMap<int, int> map; - map.insert(42, 84); - map.erase(42); - return !map.has(42) && !map.find(42); -} - -bool test_size() { - OrderedHashMap<int, int> map; - map.insert(42, 84); - map.insert(123, 84); - map.insert(123, 84); - map.insert(0, 84); - map.insert(123485, 84); - - return map.size() == 4; -} - -bool test_iteration() { - OrderedHashMap<int, int> map; - map.insert(42, 84); - map.insert(123, 12385); - map.insert(0, 12934); - map.insert(123485, 1238888); - map.insert(123, 111111); - - Vector<Pair<int, int>> expected; - expected.push_back(Pair<int, int>(42, 84)); - expected.push_back(Pair<int, int>(123, 111111)); - expected.push_back(Pair<int, int>(0, 12934)); - expected.push_back(Pair<int, int>(123485, 1238888)); - - int idx = 0; - for (OrderedHashMap<int, int>::Element E = map.front(); E; E = E.next()) { - if (expected[idx] != Pair<int, int>(E.key(), E.value())) { - return false; - } - ++idx; - } - return true; -} - -bool test_const_iteration(const OrderedHashMap<int, int> &map) { - Vector<Pair<int, int>> expected; - expected.push_back(Pair<int, int>(42, 84)); - expected.push_back(Pair<int, int>(123, 111111)); - expected.push_back(Pair<int, int>(0, 12934)); - expected.push_back(Pair<int, int>(123485, 1238888)); - - int idx = 0; - for (OrderedHashMap<int, int>::ConstElement E = map.front(); E; E = E.next()) { - if (expected[idx] != Pair<int, int>(E.key(), E.value())) { - return false; - } - ++idx; - } - return true; -} - -bool test_const_iteration() { - OrderedHashMap<int, int> map; - map.insert(42, 84); - map.insert(123, 12385); - map.insert(0, 12934); - map.insert(123485, 1238888); - map.insert(123, 111111); - - return test_const_iteration(map); -} - -typedef bool (*TestFunc)(); - -TestFunc test_funcs[] = { - - test_insert, - test_insert_overwrite, - test_erase_via_element, - test_erase_via_key, - test_size, - test_iteration, - test_const_iteration, - nullptr - -}; - -MainLoop *test() { - int count = 0; - int passed = 0; - - 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\n\n"); - OS::get_singleton()->print("*************\n"); - OS::get_singleton()->print("***TOTALS!***\n"); - OS::get_singleton()->print("*************\n"); - - OS::get_singleton()->print("Passed %i of %i tests\n", passed, count); - - return nullptr; -} - -} // namespace TestOrderedHashMap diff --git a/tests/test_ordered_hash_map.h b/tests/test_ordered_hash_map.h index f251da0ba2..3182c391cb 100644 --- a/tests/test_ordered_hash_map.h +++ b/tests/test_ordered_hash_map.h @@ -31,11 +31,109 @@ #ifndef TEST_ORDERED_HASH_MAP_H #define TEST_ORDERED_HASH_MAP_H -#include "core/os/main_loop.h" +#include "core/ordered_hash_map.h" +#include "core/os/os.h" +#include "core/pair.h" +#include "core/vector.h" + +#include "tests/test_macros.h" namespace TestOrderedHashMap { -MainLoop *test(); +TEST_CASE("[OrderedHashMap] Insert element") { + OrderedHashMap<int, int> map; + OrderedHashMap<int, int>::Element e = map.insert(42, 84); + + CHECK(e); + CHECK(e.key() == 42); + CHECK(e.get() == 84); + CHECK(e.value() == 84); + CHECK(map[42] == 84); + CHECK(map.has(42)); + CHECK(map.find(42)); +} + +TEST_CASE("[OrderedHashMap] Overwrite element") { + OrderedHashMap<int, int> map; + map.insert(42, 84); + map.insert(42, 1234); + + CHECK(map[42] == 1234); +} + +TEST_CASE("[OrderedHashMap] Erase via element") { + OrderedHashMap<int, int> map; + OrderedHashMap<int, int>::Element e = map.insert(42, 84); + + map.erase(e); + CHECK(!e); + CHECK(!map.has(42)); + CHECK(!map.find(42)); +} + +TEST_CASE("[OrderedHashMap] Erase via key") { + OrderedHashMap<int, int> map; + map.insert(42, 84); + map.erase(42); + CHECK(!map.has(42)); + CHECK(!map.find(42)); } +TEST_CASE("[OrderedHashMap] Size") { + OrderedHashMap<int, int> map; + map.insert(42, 84); + map.insert(123, 84); + map.insert(123, 84); + map.insert(0, 84); + map.insert(123485, 84); + + CHECK(map.size() == 4); +} + +TEST_CASE("[OrderedHashMap] Iteration") { + OrderedHashMap<int, int> map; + map.insert(42, 84); + map.insert(123, 12385); + map.insert(0, 12934); + map.insert(123485, 1238888); + map.insert(123, 111111); + + Vector<Pair<int, int>> expected; + expected.push_back(Pair<int, int>(42, 84)); + expected.push_back(Pair<int, int>(123, 111111)); + expected.push_back(Pair<int, int>(0, 12934)); + expected.push_back(Pair<int, int>(123485, 1238888)); + + int idx = 0; + for (OrderedHashMap<int, int>::Element E = map.front(); E; E = E.next()) { + CHECK(expected[idx] == Pair<int, int>(E.key(), E.value())); + ++idx; + } +} + +TEST_CASE("[OrderedHashMap] Const iteration") { + OrderedHashMap<int, int> map; + map.insert(42, 84); + map.insert(123, 12385); + map.insert(0, 12934); + map.insert(123485, 1238888); + map.insert(123, 111111); + + const OrderedHashMap<int, int> const_map = map; + + Vector<Pair<int, int>> expected; + expected.push_back(Pair<int, int>(42, 84)); + expected.push_back(Pair<int, int>(123, 111111)); + expected.push_back(Pair<int, int>(0, 12934)); + expected.push_back(Pair<int, int>(123485, 1238888)); + + int idx = 0; + for (OrderedHashMap<int, int>::ConstElement E = const_map.front(); E; E = E.next()) { + CHECK(expected[idx] == Pair<int, int>(E.key(), E.value())); + ++idx; + } +} + +} // namespace TestOrderedHashMap + #endif // TEST_ORDERED_HASH_MAP_H |