AttributesImpl::AttributesImpl(const AttributesImpl&	theSource,
                               MemoryManagerType&      theManager) :
	AttributesType(),
	m_attributesVector(theManager),
    m_cacheVector(theManager)
{
	// Use the assignment operator to do the dirty work...
	*this = theSource;

	assert(getLength() == theSource.getLength());
}
Пример #2
0
void AttributesImplTest::testNoNamespaces()
{
	AttributesImpl attrs;

	assert (attrs.getLength() == 0);
	assert (attrs.getIndex("foo") == -1);
	assert (attrs.getValue("foo").empty());
	
	attrs.addAttribute("", "", "a1", "CDATA", "v1");
	assert (attrs.getLength() == 1);
	assert (attrs.getIndex("a1") == 0);
	assert (attrs.getQName(0) == "a1");
	assert (attrs.getType(0) == "CDATA");
	assert (attrs.getValue(0) == "v1");
	assert (attrs.isSpecified(0));
	
	assert (attrs.getType("a1") == "CDATA");
	assert (attrs.getValue("a1") == "v1");

	attrs.addAttribute("", "", "a2", "CDATA", "v2");
	assert (attrs.getLength() == 2);
	assert (attrs.getIndex("a2") == 1);
	assert (attrs.getQName(1) == "a2");
	assert (attrs.getType(1) == "CDATA");
	assert (attrs.getValue(1) == "v2");
	assert (attrs.isSpecified(1));
	
	assert (attrs.getType("a2") == "CDATA");
	assert (attrs.getValue("a2") == "v2");

	attrs.addAttribute("", "", "a3", "CDATA", "v3");
	assert (attrs.getLength() == 3);
	assert (attrs.getIndex("a3") == 2);	
	assert (attrs.getValue("a3") == "v3");
	
	attrs.removeAttribute(0);
	assert (attrs.getLength() == 2);
	assert (attrs.getIndex("a1") == -1);
	assert (attrs.getIndex("a2") == 0);
	assert (attrs.getIndex("a3") == 1);
	assert (attrs.getQName(0) == "a2");
	assert (attrs.getQName(1) == "a3");
	
	attrs.removeAttribute("a3");
	assert (attrs.getLength() == 1);
	assert (attrs.getIndex("a1") == -1);
	assert (attrs.getIndex("a2") == 0);
	assert (attrs.getIndex("a3") == -1);
	assert (attrs.getQName(0) == "a2");
}