void testGetAttribute_Namespaced() { AttributeMap testling; testling.addAttribute("lang", "", "nl"); testling.addAttribute("lang", "http://www.w3.org/XML/1998/namespace", "en"); testling.addAttribute("lang", "", "fr"); CPPUNIT_ASSERT_EQUAL(std::string("en"), testling.getAttribute("lang", "http://www.w3.org/XML/1998/namespace")); }
static void handleStartElement(void* parser, const xmlChar* name, const xmlChar*, const xmlChar* xmlns, int, const xmlChar**, int nbAttributes, int nbDefaulted, const xmlChar ** attributes) { AttributeMap attributeValues; if (nbDefaulted != 0) { // Just because i don't understand what this means yet :-) std::cerr << "Unexpected nbDefaulted on XML element" << std::endl; } for (int i = 0; i < nbAttributes*5; i += 5) { std::string attributeNS = ""; if (attributes[i+2]) { attributeNS = std::string(reinterpret_cast<const char*>(attributes[i+2])); } attributeValues.addAttribute(std::string(reinterpret_cast<const char*>(attributes[i])), attributeNS, std::string(reinterpret_cast<const char*>(attributes[i+3]), attributes[i+4]-attributes[i+3])); } static_cast<XMLParser*>(parser)->getClient()->handleStartElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : std::string()), attributeValues); }
void testGetBoolAttribute_Invalid() { AttributeMap testling; testling.addAttribute("foo", "", "bla"); CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true)); }
void testGetBoolAttribute_False() { AttributeMap testling; testling.addAttribute("foo", "", "false"); CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true)); }
void testGetBoolAttribute_1() { AttributeMap testling; testling.addAttribute("foo", "", "1"); CPPUNIT_ASSERT(testling.getBoolAttribute("foo")); }