Some stub tests for scalar properties.
authorCarl Hetherington <carl@carlh.net>
Fri, 2 Apr 2010 15:35:36 +0000 (15:35 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 2 Apr 2010 15:35:36 +0000 (15:35 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6835 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/pbd/test/scalar_properties.cc [new file with mode: 0644]
libs/pbd/test/scalar_properties.h [new file with mode: 0644]
libs/pbd/test/xpath.cc
libs/pbd/wscript

diff --git a/libs/pbd/test/scalar_properties.cc b/libs/pbd/test/scalar_properties.cc
new file mode 100644 (file)
index 0000000..f85b108
--- /dev/null
@@ -0,0 +1,20 @@
+#include "scalar_properties.h"
+
+using namespace PBD;
+
+ScalarPropertiesTest::testBasic ()
+{
+       CPPUNIT_ASSERT (_property.changed() == false);
+       
+       _property = 4;
+       CPPUNIT_ASSERT (_property == 4);
+       CPPUNIT_ASSERT (_property.changed() == true);
+
+       _property = 5;
+       CPPUNIT_ASSERT (_property == 5);
+       CPPUNIT_ASSERT (_property.changed() == true);
+
+       PropertyList undo;
+       PropertyList redo;
+       _property.diff (undo, redo);
+}
diff --git a/libs/pbd/test/scalar_properties.h b/libs/pbd/test/scalar_properties.h
new file mode 100644 (file)
index 0000000..a3719fb
--- /dev/null
@@ -0,0 +1,15 @@
+#include <cppunit/TestFixture.h>
+#include "pbd/properties.h"
+
+class ScalarPropertiesTest : public CppUnit::TestFixture
+{
+public:
+       CPPUNIT_TEST_SUITE (ScalarPropertiesTest);
+       CPPUNIT_TEST (testBasic);
+       CPPUNIT_TEST_SUITE_END ();
+
+       void testBasic ();
+
+private:
+       PBD::Property<int> _property;
+};
index 237bf8fa640b4219adeff71aa4f6c42e0454562e..d96bd41cd2d05fca1c566a28139c03ba5954c378 100644 (file)
@@ -1,13 +1,17 @@
 #include "assert.h"
 #include <iostream>
 
+#include "xpath.h"
 #include "pbd/xml++.h"
 
+CPPUNIT_TEST_SUITE_REGISTRATION (XPathTest);
+
 using namespace std;
 
-string const prefix = "../../libs/pbd/test/";
+static string const prefix = "../../libs/pbd/test/";
 
-int main()
+void
+XPathTest::testMisc ()
 {
        cout << "Test 1: RosegardenPatchFile.xml: Find all banks in the file" << endl;
        XMLTree  doc(prefix + "RosegardenPatchFile.xml");
@@ -20,10 +24,10 @@ int main()
        for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
                assert((*i)->name() == "bank");
                assert((*i)->property("name"));
-               cout << "Found bank number " << counter++ << " with name: " << (*i)->property("name")->value() << endl;
+//             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 " << (*j)->property("id")->value() << 
-                               " with name: " << (*j)->property("name")->value() << endl;
+//                     cout << "\t found program " << (*j)->property("id")->value() << 
+//                             " with name: " << (*j)->property("name")->value() << endl;
                }
        }
        
@@ -33,11 +37,11 @@ int main()
        assert(result->size() == 5);
        
        for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
-               cout << "\t found program " << (*i)->property("id")->value() << 
-                       " with name: " << (*i)->property("name")->value() << endl;
+//             cout << "\t found program " << (*i)->property("id")->value() << 
+//                     " with name: " << (*i)->property("name")->value() << endl;
        }
 
-       cout << endl << endl << "Test 3: TestSession.ardour: find all Sources where captured-for contains the string 'Guitar'" << endl;
+//     cout << endl << endl << "Test 3: TestSession.ardour: find all Sources where captured-for contains the string 'Guitar'" << endl;
        
        // We have to allocate a new document here, or we get segfaults
        XMLTree doc2(prefix + "TestSession.ardour");
@@ -45,8 +49,8 @@ int main()
        assert(result->size() == 16);
        
        for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
-               cout << "\t found source '" << (*i)->property("name")->value() << 
-                       "' with id: " << (*i)->property("id")->value() << endl;
+//             cout << "\t found source '" << (*i)->property("name")->value() << 
+//                     "' with id: " << (*i)->property("id")->value() << endl;
        }
        
        cout << endl << endl << "Test 4: TestSession.ardour: Find all elements with an 'id' and 'name' attribute" << endl;
@@ -56,9 +60,9 @@ int main()
        for(XMLSharedNodeList::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;
+//             cout << "\t found element '" << (*i)->name() << 
+//                     "' with id: "  << (*i)->property("id")->value() << 
+//                             "' and name: " << (*i)->property("name")->value() << endl;
        }
        
        cout << endl << endl << "Test 5: ProtoolsPatchFile.midnam: Get Banks and Patches for 'Name Set 1'" << endl;
@@ -69,11 +73,11 @@ int main()
        assert(result->size() == 16);
        
        for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
-               cout << "\t found Patchbank " << (*i)->property("Name")->value() << endl;
+//             cout << "\t found Patchbank " << (*i)->property("Name")->value() << endl;
                boost::shared_ptr<XMLSharedNodeList> patches = (*i)->find("//Patch[@Name]");
                for(XMLSharedNodeList::const_iterator p = patches->begin(); p != patches->end(); ++p) {
-                       cout << "\t\t found patch number " << (*p)->property("Number")->value() 
-                            << " with name: " << (*p)->property("Name")->value()  << endl;
+//                     cout << "\t\t found patch number " << (*p)->property("Number")->value() 
+//                          << " with name: " << (*p)->property("Name")->value()  << endl;
                }
        }
 
@@ -82,8 +86,8 @@ int main()
        
        for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
                boost::shared_ptr<XMLNode> node = (*i);
-               cout << "\t found attribute node: " << node->name()  
-                    << " value: " << node->attribute_value() << endl;
+//             cout << "\t found attribute node: " << node->name()  
+//                  << " value: " << node->attribute_value() << endl;
        }       
        
        cout << endl << endl << "Test 6: ProtoolsPatchFile.midnam: Find available channels on 'Name Set 1'" << endl;
@@ -93,8 +97,8 @@ int main()
        assert(result->size() == 15);
        for(XMLSharedNodeList::const_iterator i = result->begin(); i != result->end(); ++i) {
                boost::shared_ptr<XMLNode> node = (*i);
-               cout << "\t found available Channel: " << node->name()  
-                    << " value: " << node->attribute_value() << endl;
+//             cout << "\t found available Channel: " << node->name()  
+//                  << " value: " << node->attribute_value() << endl;
        }       
        
 }
index 717fda8d4576c794c676c767f9c0c9d252b79bc5..81174d1262b0425946aaa7128009c56b9694d151 100644 (file)
@@ -111,11 +111,13 @@ def build(bld):
                # Unit tests
                testobj              = bld.new_task_gen('cxx', 'program')
                testobj.source       = '''
+                        test/testrunner.cc
                        test/xpath.cc
+                        test/scalar_properties.cc
                '''.split()
                testobj.target       = 'run-tests'
                testobj.includes     = obj.includes + ['test', '../pbd']
-               testobj.uselib       = 'XML'
+               testobj.uselib       = 'CPPUNIT XML'
                testobj.uselib_local = 'libpbd'
 
 def shutdown():