#include "lldb/Host/XML.h"
#include "gtest/gtest.h"
usingnamespacelldb_private;
#if LLDB_ENABLE_LIBXML2
static void assertGetElement(XMLNode &root, const char *element_name,
bool expected_uint_success, uint64_t expected_uint,
bool expected_double_success,
double expected_double) { … }
#define ASSERT_GET(element_name, ...) …
TEST(XML, GetAs) { … }
#else
TEST(XML, GracefulNoXML) {
std::string test_xml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<test>\n"
" <text attribute=\"123\">123</text>\n"
"</test>\n";
XMLDocument doc;
ASSERT_FALSE(doc.ParseMemory(test_xml.data(), test_xml.size()));
XMLNode root = doc.GetRootElement();
EXPECT_FALSE(root.IsValid());
XMLNode node = root.FindFirstChildElementWithName("text");
EXPECT_FALSE(node.IsValid());
uint64_t uint_val;
EXPECT_FALSE(node.GetElementTextAsUnsigned(uint_val, 66, 0));
EXPECT_EQ(uint_val, 66U);
EXPECT_FALSE(node.GetAttributeValueAsUnsigned("attribute", uint_val, 66, 0));
EXPECT_EQ(uint_val, 66U);
double double_val;
EXPECT_FALSE(node.GetElementTextAsFloat(double_val, 66.0));
EXPECT_EQ(double_val, 66.0);
}
#endif