* added more tests and profiling for pbd/xml++ xpath support

git-svn-id: svn://localhost/ardour2/branches/3.0@3387 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier
2008-05-22 16:02:05 +00:00
parent 376263d925
commit 8a97a89f3e
3 changed files with 3448 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
test: xpath
LD_LIBRARY_PATH=..:../../sigc++2:../../glibmm2 ./xpath
LD_LIBRARY_PATH=..:../../sigc++2:../../glibmm2 gprof ./xpath
xpath: xpath.cc
gcc -o $@ -g -I.. `xml2-config --libs --cflags` -L.. -L../../sigc++2 -L../../glibmm2 -lstdc++ -lpbd -lglibmm2 -lsigc++2 $<
gcc -o $@ -g -pg -I.. `xml2-config --libs --cflags` -L.. -L../../sigc++2 -L../../glibmm2 -lstdc++ -lpbd -lglibmm2 -lsigc++2 $<

File diff suppressed because it is too large Load Diff

View File

@@ -7,12 +7,12 @@ using namespace std;
int main()
{
cout << "Test 1: Find all banks in the file" << endl;
XMLTree doc("./rosegardenpatchfile.xml");
XMLNode* root = doc.root();
// "//bank" gives as last element an empty element libxml bug????
XMLNodeList* result = root->find("//bank[@name]");
XMLNodeList* result = doc.root()->find("//bank[@name]");
cerr << "Found " << result->size() << " banks" << endl;
cout << "Found " << result->size() << " banks" << endl;
assert(result->size() == 8);
int counter = 1;
for(XMLNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
@@ -20,7 +20,57 @@ int main()
assert((*i)->property("name"));
cout << "Found bank number " << counter++ << " with name: " << (*i)->property("name")->value() << endl;
for(XMLNodeList::const_iterator j = (*i)->children().begin(); j != (*i)->children().end(); ++j) {
cout << "\t found program with name: " << (*j)->property("name")->value() << endl;
cout << "\t found program " << (*j)->property("id")->value() <<
" with name: " << (*j)->property("name")->value() << endl;
}
delete *i;
}
delete result;
cout << endl << endl << "Test 2: Find all programs whose program name contains 'Latin'" << endl;
result = doc.root()->find("/rosegarden-data/studio/device/bank/program[contains(@name, 'Latin')]");
assert(result->size() == 5);
for(XMLNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
cout << "\t found program " << (*i)->property("id")->value() <<
" with name: " << (*i)->property("name")->value() << endl;
delete *i;
}
delete result;
cout << endl << endl << "Test 3: find all Sources where captured-for contains the string 'Guitar'" << endl;
XMLTree doc2("./TestSession.ardour");
result = doc2.root()->find("/Session/Sources/Source[contains(@captured-for, 'Guitar')]");
assert(result->size() == 16);
for(XMLNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
cout << "\t found source '" << (*i)->property("name")->value() <<
"' with id: " << (*i)->property("id")->value() << endl;
delete *i;
}
delete result;
cout << endl << endl << "Test 4: Find all elements with an 'id' and 'name' attribute" << endl;
result = doc2.root()->find("//*[@id and @name]");
for(XMLNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
assert((*i)->property("id"));
assert((*i)->property("name"));
cout << "\t found element '" << (*i)->name() <<
"' with id: " << (*i)->property("id")->value() <<
"' and name: " << (*i)->property("name")->value() << endl;
delete *i;
}
delete result;
}