|
|
@@ -208,6 +208,50 @@ TestReplaceXmlAttribute() { |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
// Duplicate element.
|
|
|
|
Content = "<!-- License file created by SNFIdentity-->\n"
|
|
|
@@ -228,7 +272,7 @@ TestReplaceXmlAttribute() { |
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
|
std::cout << "Duplicate TestElement: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Missing element.
|
|
|
@@ -248,7 +292,6 @@ TestReplaceXmlAttribute() { |
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
|
std::cout << "Missing TestElement: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
@@ -270,7 +313,6 @@ TestReplaceXmlAttribute() { |
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
|
std::cout << "No closing to TestElement: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
@@ -292,7 +334,6 @@ TestReplaceXmlAttribute() { |
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
|
std::cout << "Duplicate attribute: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
@@ -316,7 +357,6 @@ TestReplaceXmlAttribute() { |
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
|
std::cout << "TestAttribute in another element: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
@@ -338,7 +378,6 @@ TestReplaceXmlAttribute() { |
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
|
std::cout << "Missing attribute: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
@@ -361,7 +400,6 @@ TestReplaceXmlAttribute() { |
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (std::exception &e) {
|
|
|
|
std::cout << "No closing to attribute: " << e.what() << "\n\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|