fix: normalize MITC4 reference identities
This commit is contained in:
@@ -87,7 +87,13 @@ CaseEvidence runCase(
|
||||
auto comparisonResult = fesa::test::Mitc4ReferenceComparison::compare(
|
||||
{caseId, sourceElementType, input, csv, results});
|
||||
if (!comparisonResult.hasValue()) {
|
||||
ADD_FAILURE() << "MITC4 comparison precheck failed for " << caseId;
|
||||
std::string diagnostics;
|
||||
for (const auto& diagnostic :
|
||||
comparisonResult.status().diagnostics()) {
|
||||
diagnostics += "\n" + diagnostic.code + ": " + diagnostic.message;
|
||||
}
|
||||
ADD_FAILURE() << "MITC4 comparison precheck failed for " << caseId
|
||||
<< diagnostics;
|
||||
return {{}, comparison};
|
||||
}
|
||||
EXPECT_TRUE(
|
||||
|
||||
@@ -120,13 +120,25 @@ double parseFiniteDouble(const std::string& field) {
|
||||
return value;
|
||||
}
|
||||
|
||||
std::string uppercaseAscii(std::string value) {
|
||||
std::transform(
|
||||
value.begin(), value.end(), value.begin(), [](const char character) {
|
||||
return character >= 'a' && character <= 'z'
|
||||
? static_cast<char>(character - 'a' + 'A')
|
||||
: character;
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
||||
struct IdentityKey {
|
||||
std::string instanceName;
|
||||
std::int64_t sourceNodeLabel;
|
||||
|
||||
bool operator<(const IdentityKey& other) const noexcept {
|
||||
if (instanceName != other.instanceName) {
|
||||
return instanceName < other.instanceName;
|
||||
bool operator<(const IdentityKey& other) const {
|
||||
const std::string normalizedInstance = uppercaseAscii(instanceName);
|
||||
const std::string normalizedOther = uppercaseAscii(other.instanceName);
|
||||
if (normalizedInstance != normalizedOther) {
|
||||
return normalizedInstance < normalizedOther;
|
||||
}
|
||||
return sourceNodeLabel < other.sourceNodeLabel;
|
||||
}
|
||||
|
||||
@@ -540,6 +540,9 @@ TEST(Mitc4ReferenceComparison, MapsTrimmedHeaderAndSixComponentsBySourceIdentity
|
||||
ContractFixture fixture{"mapping"};
|
||||
auto csvRows = defaultRows();
|
||||
std::reverse(csvRows.begin(), csvRows.end());
|
||||
for (auto& row : csvRows) {
|
||||
row.instanceName = "part-1-1";
|
||||
}
|
||||
writeCsv(
|
||||
fixture.csv(), csvRows,
|
||||
" Part Instance Name , Node Label , U-U1 , U-U2 , U-U3 , "
|
||||
|
||||
Reference in New Issue
Block a user