Exemplo n.º 1
0
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"));
}
Exemplo n.º 2
0
TEST(TestMeiElement, TestAddAttributeByStrings) {
    MeiElement *p = new MeiElement("note");
    p->addAttribute("pname", "c");
    
    ASSERT_TRUE(p->hasAttribute("pname"));
    ASSERT_EQ("c", p->getAttribute("pname")->getValue());
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
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());
}
Exemplo n.º 5
0
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());
}