diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/math/test_vector2i.h | 8 | ||||
-rw-r--r-- | tests/core/math/test_vector3i.h | 8 | ||||
-rw-r--r-- | tests/core/math/test_vector4i.h | 8 | ||||
-rw-r--r-- | tests/core/string/test_string.h | 25 | ||||
-rw-r--r-- | tests/scene/test_text_edit.h | 4 |
5 files changed, 40 insertions, 13 deletions
diff --git a/tests/core/math/test_vector2i.h b/tests/core/math/test_vector2i.h index c7a0dccdcc..9ee844ffa8 100644 --- a/tests/core/math/test_vector2i.h +++ b/tests/core/math/test_vector2i.h @@ -131,12 +131,16 @@ TEST_CASE("[Vector2i] Other methods") { "Vector2i aspect should work as expected."); CHECK_MESSAGE( - Vector2i(1, 2) == vector.min(Vector2i(3, 2)), + vector.min(Vector2i(3, 2)) == Vector2i(1, 2), "Vector2i min should return expected value."); CHECK_MESSAGE( - Vector2i(5, 3) == vector.max(Vector2i(5, 2)), + vector.max(Vector2i(5, 2)) == Vector2i(5, 3), "Vector2i max should return expected value."); + + CHECK_MESSAGE( + vector.snapped(Vector2i(4, 2)) == Vector2i(0, 4), + "Vector2i snapped should work as expected."); } TEST_CASE("[Vector2i] Abs and sign methods") { diff --git a/tests/core/math/test_vector3i.h b/tests/core/math/test_vector3i.h index 56578f99eb..45240bd2ff 100644 --- a/tests/core/math/test_vector3i.h +++ b/tests/core/math/test_vector3i.h @@ -127,6 +127,14 @@ TEST_CASE("[Vector3i] Operators") { "Vector3i constructed from Vector3 should work as expected."); } +TEST_CASE("[Vector3i] Other methods") { + const Vector3i vector = Vector3i(1, 3, -7); + + CHECK_MESSAGE( + vector.snapped(Vector3i(4, 2, 5)) == Vector3i(0, 4, -5), + "Vector3i snapped should work as expected."); +} + TEST_CASE("[Vector3i] Abs and sign methods") { const Vector3i vector1 = Vector3i(1, 3, 5); const Vector3i vector2 = Vector3i(1, -3, -5); diff --git a/tests/core/math/test_vector4i.h b/tests/core/math/test_vector4i.h index 30d38607dd..8a9522f9cc 100644 --- a/tests/core/math/test_vector4i.h +++ b/tests/core/math/test_vector4i.h @@ -130,6 +130,14 @@ TEST_CASE("[Vector4i] Operators") { "Vector4i constructed from Vector4 should work as expected."); } +TEST_CASE("[Vector3i] Other methods") { + const Vector4i vector = Vector4i(1, 3, -7, 13); + + CHECK_MESSAGE( + vector.snapped(Vector4i(4, 2, 5, 8)) == Vector4i(0, 4, -5, 16), + "Vector4i snapped should work as expected."); +} + TEST_CASE("[Vector4i] Abs and sign methods") { const Vector4i vector1 = Vector4i(1, 3, 5, 7); const Vector4i vector2 = Vector4i(1, -3, -5, 7); diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index 7e4e3aa9f0..659d451d76 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -226,6 +226,12 @@ TEST_CASE("[String] Comparisons (equal)") { CHECK(s == U"Test Compare"); CHECK(s == L"Test Compare"); CHECK(s == String("Test Compare")); + + CharString empty = ""; + CharString cs = "Test Compare"; + CHECK(!(empty == cs)); + CHECK(!(cs == empty)); + CHECK(cs == CharString("Test Compare")); } TEST_CASE("[String] Comparisons (not equal)") { @@ -516,21 +522,22 @@ TEST_CASE("[String] Splitting") { s = "1.2;2.3 4.5"; const double slices_d[3] = { 1.2, 2.3, 4.5 }; - Vector<float> f; - f = s.split_floats(";"); - CHECK(f.size() == 2); - for (int i = 0; i < f.size(); i++) { - CHECK(ABS(f[i] - slices_d[i]) <= 0.00001); + Vector<double> d_arr; + d_arr = s.split_floats(";"); + CHECK(d_arr.size() == 2); + for (int i = 0; i < d_arr.size(); i++) { + CHECK(ABS(d_arr[i] - slices_d[i]) <= 0.00001); } Vector<String> keys; keys.push_back(";"); keys.push_back(" "); - f = s.split_floats_mk(keys); - CHECK(f.size() == 3); - for (int i = 0; i < f.size(); i++) { - CHECK(ABS(f[i] - slices_d[i]) <= 0.00001); + Vector<float> f_arr; + f_arr = s.split_floats_mk(keys); + CHECK(f_arr.size() == 3); + for (int i = 0; i < f_arr.size(); i++) { + CHECK(ABS(f_arr[i] - slices_d[i]) <= 0.00001); } s = "1;2 4"; diff --git a/tests/scene/test_text_edit.h b/tests/scene/test_text_edit.h index 5dad7d06e1..6d1c2f4f2e 100644 --- a/tests/scene/test_text_edit.h +++ b/tests/scene/test_text_edit.h @@ -3261,8 +3261,8 @@ TEST_CASE("[SceneTree][TextEdit] mouse") { CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y - 100), false) == Point2i(90, 0)); CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y)) == Point2i(90, 0)); - CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x, end_pos.y + 100)) == Point2i(141, 0)); - CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y + 100)) == Point2i(141, 0)); + CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x, end_pos.y + 100)) == Point2i(140, 0)); + CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y + 100)) == Point2i(140, 0)); CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x, end_pos.y - 100)) == Point2i(104, 0)); CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y - 100)) == Point2i(90, 0)); |