diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/core/math/test_basis.h | 30 | ||||
| -rw-r--r-- | tests/core/math/test_transform_2d.h | 30 | ||||
| -rw-r--r-- | tests/scene/test_code_edit.h | 78 | ||||
| -rw-r--r-- | tests/test_main.cpp | 4 |
4 files changed, 140 insertions, 2 deletions
diff --git a/tests/core/math/test_basis.h b/tests/core/math/test_basis.h index 0a34954bd3..fcac9a6231 100644 --- a/tests/core/math/test_basis.h +++ b/tests/core/math/test_basis.h @@ -296,6 +296,36 @@ TEST_CASE("[Basis] Finite number checks") { "Basis with three components infinite should not be finite."); } +TEST_CASE("[Basis] Is conformal checks") { + CHECK_MESSAGE( + Basis().is_conformal(), + "Identity Basis should be conformal."); + + CHECK_MESSAGE( + Basis::from_euler(Vector3(1.2, 3.4, 5.6)).is_conformal(), + "Basis with only rotation should be conformal."); + + CHECK_MESSAGE( + Basis::from_scale(Vector3(-1, -1, -1)).is_conformal(), + "Basis with only a flip should be conformal."); + + CHECK_MESSAGE( + Basis::from_scale(Vector3(1.2, 1.2, 1.2)).is_conformal(), + "Basis with only uniform scale should be conformal."); + + CHECK_MESSAGE( + Basis(Vector3(3, 4, 0), Vector3(4, -3, 0.0), Vector3(0, 0, 5)).is_conformal(), + "Basis with a flip, rotation, and uniform scale should be conformal."); + + CHECK_FALSE_MESSAGE( + Basis::from_scale(Vector3(1.2, 3.4, 5.6)).is_conformal(), + "Basis with non-uniform scale should not be conformal."); + + CHECK_FALSE_MESSAGE( + Basis(Vector3(Math_SQRT12, Math_SQRT12, 0), Vector3(0, 1, 0), Vector3(0, 0, 1)).is_conformal(), + "Basis with the X axis skewed 45 degrees should not be conformal."); +} + } // namespace TestBasis #endif // TEST_BASIS_H diff --git a/tests/core/math/test_transform_2d.h b/tests/core/math/test_transform_2d.h index ca27776180..36d27ce7a9 100644 --- a/tests/core/math/test_transform_2d.h +++ b/tests/core/math/test_transform_2d.h @@ -130,6 +130,36 @@ TEST_CASE("[Transform2D] Finite number checks") { "Transform2D with three components infinite should not be finite."); } +TEST_CASE("[Transform2D] Is conformal checks") { + CHECK_MESSAGE( + Transform2D().is_conformal(), + "Identity Transform2D should be conformal."); + + CHECK_MESSAGE( + Transform2D(1.2, Vector2()).is_conformal(), + "Transform2D with only rotation should be conformal."); + + CHECK_MESSAGE( + Transform2D(Vector2(1, 0), Vector2(0, -1), Vector2()).is_conformal(), + "Transform2D with only a flip should be conformal."); + + CHECK_MESSAGE( + Transform2D(Vector2(1.2, 0), Vector2(0, 1.2), Vector2()).is_conformal(), + "Transform2D with only uniform scale should be conformal."); + + CHECK_MESSAGE( + Transform2D(Vector2(1.2, 3.4), Vector2(3.4, -1.2), Vector2()).is_conformal(), + "Transform2D with a flip, rotation, and uniform scale should be conformal."); + + CHECK_FALSE_MESSAGE( + Transform2D(Vector2(1.2, 0), Vector2(0, 3.4), Vector2()).is_conformal(), + "Transform2D with non-uniform scale should not be conformal."); + + CHECK_FALSE_MESSAGE( + Transform2D(Vector2(Math_SQRT12, Math_SQRT12), Vector2(0, 1), Vector2()).is_conformal(), + "Transform2D with the X axis skewed 45 degrees should not be conformal."); +} + } // namespace TestTransform2D #endif // TEST_TRANSFORM_2D_H diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h index 8576b38ce2..b44a47bf8a 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -3886,6 +3886,84 @@ TEST_CASE("[SceneTree][CodeEdit] New Line") { memdelete(code_edit); } +TEST_CASE("[SceneTree][CodeEdit] Duplicate Lines") { + CodeEdit *code_edit = memnew(CodeEdit); + SceneTree::get_singleton()->get_root()->add_child(code_edit); + code_edit->grab_focus(); + + code_edit->set_text(R"(extends Node + +func _ready(): + var a := len(OS.get_cmdline_args()) + var b := get_child_count() + var c := a + b + for i in range(c): + print("This is the solution: ", sin(i)) + var pos = get_index() - 1 + print("Make sure this exits: %b" % pos) +)"); + + /* Duplicate a single line without selection. */ + code_edit->set_caret_line(0); + code_edit->duplicate_lines(); + CHECK(code_edit->get_line(0) == "extends Node"); + CHECK(code_edit->get_line(1) == "extends Node"); + CHECK(code_edit->get_line(2) == ""); + + /* Duplicate multiple lines with selection. */ + code_edit->set_caret_line(6); + code_edit->set_caret_column(15); + code_edit->select(4, 8, 6, 15); + code_edit->duplicate_lines(); + CHECK(code_edit->get_line(6) == "\tvar c := a + b"); + CHECK(code_edit->get_line(7) == "\tvar a := len(OS.get_cmdline_args())"); + CHECK(code_edit->get_line(8) == "\tvar b := get_child_count()"); + CHECK(code_edit->get_line(9) == "\tvar c := a + b"); + CHECK(code_edit->get_line(10) == "\tfor i in range(c):"); + + /* Duplicate single lines with multiple carets. */ + code_edit->deselect(); + code_edit->set_caret_line(10); + code_edit->set_caret_column(1); + code_edit->add_caret(11, 2); + code_edit->add_caret(12, 1); + code_edit->duplicate_lines(); + CHECK(code_edit->get_line(9) == "\tvar c := a + b"); + CHECK(code_edit->get_line(10) == "\tfor i in range(c):"); + CHECK(code_edit->get_line(11) == "\tfor i in range(c):"); + CHECK(code_edit->get_line(12) == "\t\tprint(\"This is the solution: \", sin(i))"); + CHECK(code_edit->get_line(13) == "\t\tprint(\"This is the solution: \", sin(i))"); + CHECK(code_edit->get_line(14) == "\tvar pos = get_index() - 1"); + CHECK(code_edit->get_line(15) == "\tvar pos = get_index() - 1"); + CHECK(code_edit->get_line(16) == "\tprint(\"Make sure this exits: %b\" % pos)"); + + /* Duplicate multiple lines with multiple carets. */ + code_edit->select(0, 0, 1, 2, 0); + code_edit->select(3, 0, 4, 2, 1); + code_edit->select(16, 0, 17, 0, 2); + code_edit->set_caret_line(1, false, true, 0, 0); + code_edit->set_caret_column(2, false, 0); + code_edit->set_caret_line(4, false, true, 0, 1); + code_edit->set_caret_column(2, false, 1); + code_edit->set_caret_line(17, false, true, 0, 2); + code_edit->set_caret_column(0, false, 2); + code_edit->duplicate_lines(); + CHECK(code_edit->get_line(1) == "extends Node"); + CHECK(code_edit->get_line(2) == "extends Node"); + CHECK(code_edit->get_line(3) == "extends Node"); + CHECK(code_edit->get_line(4) == ""); + CHECK(code_edit->get_line(6) == "\tvar a := len(OS.get_cmdline_args())"); + CHECK(code_edit->get_line(7) == "func _ready():"); + CHECK(code_edit->get_line(8) == "\tvar a := len(OS.get_cmdline_args())"); + CHECK(code_edit->get_line(9) == "\tvar b := get_child_count()"); + CHECK(code_edit->get_line(20) == "\tprint(\"Make sure this exits: %b\" % pos)"); + CHECK(code_edit->get_line(21) == ""); + CHECK(code_edit->get_line(22) == "\tprint(\"Make sure this exits: %b\" % pos)"); + CHECK(code_edit->get_line(23) == ""); + + memdelete(code_edit); +} + } // namespace TestCodeEdit #endif // TEST_CODE_EDIT_H diff --git a/tests/test_main.cpp b/tests/test_main.cpp index a43dfaa57f..8c120f6d3a 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -252,7 +252,7 @@ struct GodotTestCaseListener : public doctest::IReporter { ERR_PRINT_OFF; navigation_server_3d = NavigationServer3DManager::new_default_server(); - navigation_server_2d = memnew(NavigationServer2D); + navigation_server_2d = NavigationServer2DManager::new_default_server(); ERR_PRINT_ON; memnew(InputMap); @@ -278,7 +278,7 @@ struct GodotTestCaseListener : public doctest::IReporter { if (suite_name.find("[Navigation]") != -1 && navigation_server_2d == nullptr && navigation_server_3d == nullptr) { ERR_PRINT_OFF; navigation_server_3d = NavigationServer3DManager::new_default_server(); - navigation_server_2d = memnew(NavigationServer2D); + navigation_server_2d = NavigationServer2DManager::new_default_server(); ERR_PRINT_ON; return; } |
