Exemplo n.º 1
0
TEST(TestMeiElement, TestGetSet) {
    MeiElement *p = new MeiElement("p");
    p->setValue("this is a sentence");
    ASSERT_EQ("this is a sentence", p->getValue());

    p->setTail("atail");

    // We know an id is 'm-<uuid>', so we can check the length
    ASSERT_EQ(38, p->getId().length());
    ASSERT_EQ("atail", p->getTail());
}
Exemplo n.º 2
0
void MusMeiInput::ReadFacsTable(MeiElement *element, FacsTable *table)
{
	if (element->getChildren().size() > 0) {
		for (vector<MeiElement*>::iterator i = element->getChildren().begin(); i != element->getChildren().end(); i++) {
			MeiElement e = **i;
			if (e.getName() == "zone") {
				std::string id;
				if (e.getId() != "") {
					id = e.getId();
				} else {
					throw "missing xml:id attribute on zone element";
				}
				int ulx = atoi(e.getAttribute("ulx")->getValue().c_str());
				int uly = atoi(e.getAttribute("uly")->getValue().c_str());
				int lry = atoi(e.getAttribute("lry")->getValue().c_str());
				table->add(id, ulx, uly, lry);
			} else if (e.getName() == "system") {
				std::string id;
				if (e.getId() != "") {
					id = e.getId();
				} else {
					throw "missing xml:id attribute on system element";
				}
				std::string facs;
				if (e.getFacs() != NULL) {
					facs = e.getFacs()->getValue();
				} else {
					throw "missing facs attribute on system element";
				}
				int ulx = table->GetX(facs); //what if they haven't been stored yet? zones are always defined before systems, as the facs needs to refer to something.
				int uly = table->GetUY(facs); //"
				int lry = table->GetLY(facs);
				table->add(id, ulx, uly, lry);
			}				
			ReadFacsTable(*i,&*table);
		}
	}
}
Exemplo n.º 3
0
TEST(TestMeiElement, TestMeiElementEquality) {
    MeiElement *p = new MeiElement("one");
    MeiElement *q = new MeiElement("two");
    MeiElement *r = new MeiElement(*p);
    MeiElement *s = new MeiElement(*p);
    
    // two elements with the same name and the same ID
    string pId = p->getId();
    r->setId(pId);
    ASSERT_EQ(*p, *r);

    // two elements with different names and the same ID
    q->setId(pId);
    ASSERT_NE(*p, *q);
    
    // two elements with the same name and different IDs
    ASSERT_NE(*p, *s);
}