|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Element in comment.
|
|
|
|
|
|
Content = "<!-- License file created by SNFIdentity\n"
|
|
|
|
|
|
"<TestElement TestAttribute = \"testmode\" authentication='setuptestingonly'/>\n"
|
|
|
|
|
|
"-->\n"
|
|
|
|
|
|
"<snf>\n"
|
|
|
|
|
|
"<TestElement TestAttribute = \"testmode\" authentication='setuptestingonly'/>\n"
|
|
|
|
|
|
"</snf>\n";
|
|
|
|
|
|
OriginalContent = Content;
|
|
|
|
|
|
|
|
|
|
|
|
ExpectedContent = "<!-- License file created by SNFIdentity\n"
|
|
|
|
|
|
"<TestElement TestAttribute = \"testmode\" authentication='setuptestingonly'/>\n"
|
|
|
|
|
|
"-->\n"
|
|
|
|
|
|
"<snf>\n"
|
|
|
|
|
|
"<TestElement TestAttribute = \"NewValue\" authentication='setuptestingonly'/>\n"
|
|
|
|
|
|
"</snf>\n";
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
Utility::ReplaceXmlAttribute(&Content, ElementName, AttributeName, AttributeNewValue);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
|
|
|
std::string Temp;
|
|
|
|
|
|
|
|
|
|
|
|
Temp = "TestReplaceXmlAttribute: Unexpected exception thrown with valid input: ";
|
|
|
|
|
|
Temp += e.what();
|
|
|
|
|
|
Temp += "\n\nOriginal Content:\n\n";
|
|
|
|
|
|
Temp += OriginalContent + "\n";
|
|
|
|
|
|
Error(Temp);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Content != ExpectedContent) {
|
|
|
|
|
|
std::string Temp;
|
|
|
|
|
|
|
|
|
|
|
|
Temp = "TestReplaceXmlAttribute: Incorrect result with valid input. Content after replacement:\n\n";
|
|
|
|
|
|
Temp += Content;
|
|
|
|
|
|
Temp += "\n\nExpected:\n\n";
|
|
|
|
|
|
Temp += ExpectedContent + "\n";
|
|
|
|
|
|
Error(Temp);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
// Test with invalid input.
|
|
|
// Test with invalid input.
|
|
|
// Duplicate element.
|
|
|
// Duplicate element.
|
|
|
Content = "<!-- License file created by SNFIdentity-->\n"
|
|
|
Content = "<!-- License file created by SNFIdentity-->\n"
|
|
|
|
|
|
|
|
|
return false;
|
|
|
return false;
|
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
} catch (std::exception &e) {
|
|
|
std::cout << "Duplicate TestElement: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// Missing element.
|
|
|
// Missing element.
|
|
|
|
|
|
|
|
|
return false;
|
|
|
return false;
|
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
} catch (std::exception &e) {
|
|
|
std::cout << "Missing TestElement: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
return false;
|
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
} catch (std::exception &e) {
|
|
|
std::cout << "No closing to TestElement: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
return false;
|
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
} catch (std::exception &e) {
|
|
|
std::cout << "Duplicate attribute: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
return false;
|
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
} catch (std::exception &e) {
|
|
|
std::cout << "TestAttribute in another element: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
return false;
|
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
} catch (std::exception &e) {
|
|
|
std::cout << "Missing attribute: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
return false;
|
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
} catch (std::exception &e) {
|
|
|
std::cout << "No closing to attribute: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|