Base: simplify UnitsSchemas management

Fixes: Maintaining schemas is difficult and error-prone

- Facilitate easy schemas add, remove, change, etc.
- Remove 14 files containing approx 2,190 lines of if/else code and data
- Place data in one file (UnitsSchemasData.h) using a normalized structure (including special functions)
- Isolate and simplify data operations (code)
- Remove schemas enum to keep data independent of code
- Separate responsibilities: Specifications, data, schemas, schema
- Add schema data 'isDefault'
- Add schema data name
- Prefer algorithms to raw loops
- Add schemas unit tests
- Tweak quantity unit tests
This commit is contained in:
bofdahof
2025-01-22 09:40:00 +10:00
committed by Ladislav Michl
parent ef6f60510a
commit 1155f0d752
39 changed files with 1983 additions and 2928 deletions

View File

@@ -130,7 +130,7 @@ TEST_F(TestMaterialValue, TestQuantityType)
EXPECT_EQ(variant.toString().size(), 0);
auto quantity = variant.value<Base::Quantity>();
EXPECT_FALSE(quantity.isValid());
EXPECT_EQ(quantity.getUserString(), "nan ");
EXPECT_EQ(quantity.getUserString(), "nan");
EXPECT_TRUE(std::isnan(quantity.getValue()));
// Test a copy
@@ -146,7 +146,7 @@ TEST_F(TestMaterialValue, TestQuantityType)
EXPECT_EQ(variant.toString().size(), 0);
quantity = variant.value<Base::Quantity>();
EXPECT_FALSE(quantity.isValid());
EXPECT_EQ(quantity.getUserString(), "nan ");
EXPECT_EQ(quantity.getUserString(), "nan");
EXPECT_TRUE(std::isnan(quantity.getValue()));
}