Exemplo n.º 1
0
TEST(TestMeiElement, TestConstGetAttributes) {
    MeiElement *p = new MeiElement("note");
    MeiAttribute *attr1 = new MeiAttribute("pname", "c");
    MeiAttribute *attr2 = new MeiAttribute("oct", "4");    
    
    p->addAttribute(attr1);
    p->addAttribute(attr2);
    
    vector<MeiAttribute*> atts = p->getAttributes();
    ASSERT_EQ(2, atts.size());
    
    // Adding to the returned vector doesn't affect the element
    atts.push_back(new MeiAttribute("stem.dir", "up"));
    ASSERT_EQ(2, p->getAttributes().size());
}
Exemplo n.º 2
0
// If we get a pointer to an attribute, we can change it
TEST(TestMeiElement, TestChangeAttributeValue) {
    MeiElement *p = new MeiElement("note");
    MeiAttribute *attr1 = new MeiAttribute("pname", "c");
    p->addAttribute(attr1);
    
    vector<MeiAttribute*> atts = p->getAttributes();
    atts[0]->setValue("d");
    ASSERT_EQ("d", p->getAttribute("pname")->getValue());
}
Exemplo n.º 3
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());
}
Exemplo n.º 4
0
// Adding an attribute to an element sets the attr's element.
TEST(TestMeiElement, TestAttributeLink) {
    MeiElement *p = new MeiElement("note");
    MeiAttribute *a = new MeiAttribute("pname", "c");
    p->addAttribute(a);
    ASSERT_EQ(p, a->getElement());

    // And when adding many attrs
    MeiAttribute *b = new MeiAttribute("pname", "d");
    MeiAttribute *c = new MeiAttribute("stem.dir", "down");
    vector<MeiAttribute*> atts;
    atts.push_back(b);
    atts.push_back(c);
    p->setAttributes(atts);
    ASSERT_EQ(2, p->getAttributes().size());
    ASSERT_EQ(p, b->getElement());
    ASSERT_EQ(p, c->getElement());
}