summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_aabb.h16
-rw-r--r--tests/test_curve.h8
-rw-r--r--tests/test_json.h61
3 files changed, 35 insertions, 50 deletions
diff --git a/tests/test_aabb.h b/tests/test_aabb.h
index 39e3c6e45b..c4daa56e5a 100644
--- a/tests/test_aabb.h
+++ b/tests/test_aabb.h
@@ -278,24 +278,24 @@ TEST_CASE("[AABB] Get endpoints") {
TEST_CASE("[AABB] Get longest/shortest axis") {
const AABB aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 5, 6));
CHECK_MESSAGE(
- aabb.get_longest_axis().is_equal_approx(Vector3(0, 0, 1)),
+ aabb.get_longest_axis() == Vector3(0, 0, 1),
"get_longest_axis() should return the expected value.");
CHECK_MESSAGE(
aabb.get_longest_axis_index() == Vector3::AXIS_Z,
- "get_longest_axis() should return the expected value.");
+ "get_longest_axis_index() should return the expected value.");
CHECK_MESSAGE(
- Math::is_equal_approx(aabb.get_longest_axis_size(), 6),
- "get_longest_axis() should return the expected value.");
+ aabb.get_longest_axis_size() == 6,
+ "get_longest_axis_size() should return the expected value.");
CHECK_MESSAGE(
- aabb.get_shortest_axis().is_equal_approx(Vector3(1, 0, 0)),
+ aabb.get_shortest_axis() == Vector3(1, 0, 0),
"get_shortest_axis() should return the expected value.");
CHECK_MESSAGE(
aabb.get_shortest_axis_index() == Vector3::AXIS_X,
- "get_shortest_axis() should return the expected value.");
+ "get_shortest_axis_index() should return the expected value.");
CHECK_MESSAGE(
- Math::is_equal_approx(aabb.get_shortest_axis_size(), 4),
- "get_shortest_axis() should return the expected value.");
+ aabb.get_shortest_axis_size() == 4,
+ "get_shortest_axis_size() should return the expected value.");
}
#ifndef _MSC_VER
diff --git a/tests/test_curve.h b/tests/test_curve.h
index 3055cfd97b..7eeee86f32 100644
--- a/tests/test_curve.h
+++ b/tests/test_curve.h
@@ -80,7 +80,7 @@ TEST_CASE("[Curve] Custom curve with free tangents") {
"Custom free curve should contain the expected number of points.");
CHECK_MESSAGE(
- Math::is_equal_approx(curve->interpolate(-0.1), 0),
+ Math::is_zero_approx(curve->interpolate(-0.1)),
"Custom free curve should return the expected value at offset 0.1.");
CHECK_MESSAGE(
Math::is_equal_approx(curve->interpolate(0.1), (real_t)0.352),
@@ -99,7 +99,7 @@ TEST_CASE("[Curve] Custom curve with free tangents") {
"Custom free curve should return the expected value at offset 0.1.");
CHECK_MESSAGE(
- Math::is_equal_approx(curve->interpolate_baked(-0.1), 0),
+ Math::is_zero_approx(curve->interpolate_baked(-0.1)),
"Custom free curve should return the expected baked value at offset 0.1.");
CHECK_MESSAGE(
Math::is_equal_approx(curve->interpolate_baked(0.1), (real_t)0.352),
@@ -169,7 +169,7 @@ TEST_CASE("[Curve] Custom curve with linear tangents") {
"Custom linear curve should contain the expected number of points.");
CHECK_MESSAGE(
- Math::is_equal_approx(curve->interpolate(-0.1), 0),
+ Math::is_zero_approx(curve->interpolate(-0.1)),
"Custom linear curve should return the expected value at offset -0.1.");
CHECK_MESSAGE(
Math::is_equal_approx(curve->interpolate(0.1), (real_t)0.4),
@@ -188,7 +188,7 @@ TEST_CASE("[Curve] Custom curve with linear tangents") {
"Custom linear curve should return the expected value at offset 2.0.");
CHECK_MESSAGE(
- Math::is_equal_approx(curve->interpolate_baked(-0.1), 0),
+ Math::is_zero_approx(curve->interpolate_baked(-0.1)),
"Custom linear curve should return the expected baked value at offset -0.1.");
CHECK_MESSAGE(
Math::is_equal_approx(curve->interpolate_baked(0.1), (real_t)0.4),
diff --git a/tests/test_json.h b/tests/test_json.h
index f1cb4799dc..3af58dfa1c 100644
--- a/tests/test_json.h
+++ b/tests/test_json.h
@@ -45,75 +45,65 @@ TEST_CASE("[JSON] Parsing single data types") {
// Parsing a single data type as JSON is valid per the JSON specification.
JSON json;
- Variant result;
- String err_str;
- int err_line;
- json.parse("null", result, err_str, err_line);
+ json.parse("null");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing `null` as JSON should parse successfully.");
CHECK_MESSAGE(
- result == Variant(),
+ json.get_data() == Variant(),
"Parsing a double quoted string as JSON should return the expected value.");
- json.parse("true", result, err_str, err_line);
+ json.parse("true");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing boolean `true` as JSON should parse successfully.");
CHECK_MESSAGE(
- result,
+ json.get_data(),
"Parsing boolean `true` as JSON should return the expected value.");
- json.parse("false", result, err_str, err_line);
+ json.parse("false");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing boolean `false` as JSON should parse successfully.");
CHECK_MESSAGE(
- !result,
+ !json.get_data(),
"Parsing boolean `false` as JSON should return the expected value.");
- // JSON only has a floating-point number type, no integer type.
- // This is why we use `is_equal_approx()` for the comparison.
- json.parse("123456", result, err_str, err_line);
+ json.parse("123456");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing an integer number as JSON should parse successfully.");
CHECK_MESSAGE(
- (int)result == 123'456,
+ (int)(json.get_data()) == 123456,
"Parsing an integer number as JSON should return the expected value.");
- json.parse("0.123456", result, err_str, err_line);
+ json.parse("0.123456");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing a floating-point number as JSON should parse successfully.");
CHECK_MESSAGE(
- Math::is_equal_approx(result, 0.123456),
+ Math::is_equal_approx(double(json.get_data()), 0.123456),
"Parsing a floating-point number as JSON should return the expected value.");
- json.parse("\"hello\"", result, err_str, err_line);
+ json.parse("\"hello\"");
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing a double quoted string as JSON should parse successfully.");
CHECK_MESSAGE(
- result == "hello",
+ json.get_data() == "hello",
"Parsing a double quoted string as JSON should return the expected value.");
}
TEST_CASE("[JSON] Parsing arrays") {
JSON json;
- Variant result;
- String err_str;
- int err_line;
// JSON parsing fails if it's split over several lines (even if leading indentation is removed).
- json.parse(
- R"(["Hello", "world.", "This is",["a","json","array.",[]], "Empty arrays ahoy:", [[["Gotcha!"]]]])",
- result, err_str, err_line);
+ json.parse(R"(["Hello", "world.", "This is",["a","json","array.",[]], "Empty arrays ahoy:", [[["Gotcha!"]]]])");
- const Array array = result;
+ const Array array = json.get_data();
CHECK_MESSAGE(
- err_line == 0,
+ json.get_error_line() == 0,
"Parsing a JSON array should parse successfully.");
CHECK_MESSAGE(
array[0] == "Hello",
@@ -136,15 +126,10 @@ TEST_CASE("[JSON] Parsing arrays") {
TEST_CASE("[JSON] Parsing objects (dictionaries)") {
JSON json;
- Variant result;
- String err_str;
- int err_line;
- json.parse(
- R"({"name": "Godot Engine", "is_free": true, "bugs": null, "apples": {"red": 500, "green": 0, "blue": -20}, "empty_object": {}})",
- result, err_str, err_line);
+ json.parse(R"({"name": "Godot Engine", "is_free": true, "bugs": null, "apples": {"red": 500, "green": 0, "blue": -20}, "empty_object": {}})");
- const Dictionary dictionary = result;
+ const Dictionary dictionary = json.get_data();
CHECK_MESSAGE(
dictionary["name"] == "Godot Engine",
"The parsed JSON should contain the expected values.");