TEST(TestMeiElement, TestRemoveAttribute) { MeiElement *p = new MeiElement("note"); MeiAttribute *attr1 = new MeiAttribute("pname", "c"); p->addAttribute(attr1); ASSERT_TRUE(p->hasAttribute("pname")); p->removeAttribute("pname"); ASSERT_FALSE(p->hasAttribute("pname")); }
TEST(TestMeiElement, TestAddAttributeByStrings) { MeiElement *p = new MeiElement("note"); p->addAttribute("pname", "c"); ASSERT_TRUE(p->hasAttribute("pname")); ASSERT_EQ("c", p->getAttribute("pname")->getValue()); }
TEST(TestMeiDocument, SetsDefaultNamespace) { MeiDocument *doc = new MeiDocument(); MeiElement *root = new MeiElement("mei"); doc->setRootElement(root); ASSERT_TRUE(root->hasAttribute("xmlns")); ASSERT_EQ(root->getAttribute("xmlns")->getValue(), MEI_NS); }
TEST(TestMeiElement, TestAddAttribute) { MeiElement *p = new MeiElement("note"); MeiAttribute *attr1 = new MeiAttribute("pname", "c"); MeiAttribute *attr2 = new MeiAttribute("pname", "d"); p->addAttribute(attr1); ASSERT_TRUE(p->hasAttribute("pname")); ASSERT_EQ("c", p->getAttribute("pname")->getValue()); // Adding the same named attribute replaces it p->addAttribute(attr2); ASSERT_EQ("d", p->getAttribute("pname")->getValue()); }
TEST(TestMeiElement, TestGetSetHasAttributes) { MeiElement *p = new MeiElement("note"); MeiAttribute *attr1 = new MeiAttribute("pname", "c"); MeiAttribute *attr2 = new MeiAttribute("stem.dir", "down"); vector<MeiAttribute*> attrs; attrs.push_back(attr1); attrs.push_back(attr2); p->setAttributes(attrs); ASSERT_EQ(2, p->getAttributes().size()); ASSERT_TRUE(p->hasAttribute("pname")); ASSERT_TRUE(p->hasAttribute("stem.dir")); ASSERT_EQ("c", p->getAttribute("pname")->getValue()); // Adding a new attribute to the initial list doesn't // affect the attributes in the element attrs.push_back(new MeiAttribute("oct", "4")); ASSERT_EQ(2, p->getAttributes().size()); }