From 8929dbdeb10e76bfe240e77c89943fed2708f57c Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 13 Nov 2024 14:03:54 +0000 Subject: [PATCH] Unit tests - add explicit conversions test cases --- test/unit/core/expressions_test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/unit/core/expressions_test.cpp b/test/unit/core/expressions_test.cpp index 557117aab..d89463fa0 100644 --- a/test/unit/core/expressions_test.cpp +++ b/test/unit/core/expressions_test.cpp @@ -94,6 +94,15 @@ TEST_CASE("expressions") TRY_CHECK(parse_and_dump("'escaped \\' apostrophe'") == "'escaped \\' apostrophe'"); TRY_CHECK(parse_and_dump("'escaped \\\\ backslash'") == "'escaped \\\\ backslash'"); + // explicit conversions + TRY_CHECK(eval("int('123')") == 123); + TRY_CHECK(eval("float('3.14'+'159')") == 3.14159); + TRY_CHECK(eval("bool(-0.001)") == true); + TRY_CHECK(eval("bool(0.001)") == true); + TRY_CHECK(eval("bool(0.0)") == false); + TRY_CHECK(eval("str(123)") == tr.transcode("123")); + TRY_CHECK(eval("float(str(3.14) + str(159))") == 3.14159); + // floating point constants TRY_CHECK(parse_and_dump("pi") == "3.14159"); TRY_CHECK(parse_and_dump("deg_to_rad") == "0.0174533");