Update core library GPL boilerplate and (C) from git log
[ardour.git] / libs / pbd / test / scalar_properties.cc
index f85b1081a40ded2e0bb47e064bb2e5107d611005..be8ef206555abaeeef4a725851a6e260af4380a2 100644 (file)
@@ -1,20 +1,47 @@
 #include "scalar_properties.h"
 
+CPPUNIT_TEST_SUITE_REGISTRATION (ScalarPropertiesTest);
+
+using namespace std;
 using namespace PBD;
 
+namespace Properties {
+       PBD::PropertyDescriptor<int> fred;
+};
+
+void
+ScalarPropertiesTest::make_property_quarks ()
+{
+       Properties::fred.property_id = g_quark_from_static_string ("fred");
+}
+
+ScalarPropertiesTest::ScalarPropertiesTest ()
+       : _fred (Properties::fred, 0)
+{
+}
+
+void
 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);
+       CPPUNIT_ASSERT (_fred.changed() == false);
+
+       _fred = 4;
+       CPPUNIT_ASSERT (_fred == 4);
+       CPPUNIT_ASSERT (_fred.changed() == true);
+
+       _fred.clear_changes ();
+       CPPUNIT_ASSERT (_fred.changed() == false);
+
+       _fred = 5;
+       CPPUNIT_ASSERT (_fred == 5);
+       CPPUNIT_ASSERT (_fred.changed() == true);
+
+       PropertyList changes;
+       _fred.get_changes_as_properties (changes, 0);
+
+       CPPUNIT_ASSERT (changes.size() == 1);
+
+       PropertyTemplate<int>* t = dynamic_cast<Property<int>*> (changes.begin()->second);
+       CPPUNIT_ASSERT (t);
+       CPPUNIT_ASSERT (t->val() == 5);
 }