From 1678171e6b60292d66a492aae887f9558f97d089 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Mon, 19 May 2025 19:54:30 +0200 Subject: [PATCH] Base: Add more tests for imperial building special function --- tests/src/Base/SchemaTests.cpp | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/src/Base/SchemaTests.cpp b/tests/src/Base/SchemaTests.cpp index 0b170fa9be..412bc8ac81 100644 --- a/tests/src/Base/SchemaTests.cpp +++ b/tests/src/Base/SchemaTests.cpp @@ -315,6 +315,41 @@ TEST_F(SchemaTest, imperial_building_special_function_length_foot) EXPECT_EQ(result, expect); } +TEST_F(SchemaTest, imperial_building_special_function_zero_length) +{ + const auto result = set("ImperialBuilding", Unit::Length, 0.0); + const auto expect = Tools::escapeQuotesFromString("0"); + + EXPECT_EQ(result, expect); +} + +TEST_F(SchemaTest, imperial_building_special_function_length_negative_fraction_only) +{ + constexpr auto val {(-1.0 / 8.0) * 25.4}; // -1/8 inch in mm + const auto result = set("ImperialBuilding", Unit::Length, val); + const auto expect = Tools::escapeQuotesFromString("-1/8\""); + + EXPECT_EQ(result, expect); +} + +TEST_F(SchemaTest, imperial_building_special_function_negative_inches_and_fraction) +{ + constexpr auto val {-2.5 * 25.4}; // -2.5 inches in mm + const auto result = set("ImperialBuilding", Unit::Length, val); + const auto expect = Tools::escapeQuotesFromString("-2\" - 1/2\""); + + EXPECT_EQ(result, expect); +} + +TEST_F(SchemaTest, imperial_building_special_function_high_precision_rounding) +{ + constexpr auto val {25.396}; // Very close to exactly 1 inch + const auto result = set("ImperialBuilding", Unit::Length, val); + const auto expect = Tools::escapeQuotesFromString("1\""); + + EXPECT_EQ(result, expect); +} + TEST_F(SchemaTest, imperial_building_special_function_length) { GTEST_SKIP() << "QuantityParser::yyparse() is crashing on the >>1' 2\" + 1/4\"<< input, "