]> git.sesse.net Git - mlt/commitdiff
Add more unit tests for mlt_property.
authorDan Dennedy <dan@dennedy.org>
Fri, 3 May 2013 05:34:29 +0000 (22:34 -0700)
committerDan Dennedy <dan@dennedy.org>
Fri, 3 May 2013 05:34:29 +0000 (22:34 -0700)
src/tests/test_properties/test_properties.cpp
src/tests/test_properties/test_properties.pro

index 06dd8f246db43ef5155c7ea7a51db1308ee9a3cc..4fbe62907b0b8f95cb622684954450008c5aa90f 100644 (file)
@@ -51,6 +51,147 @@ private Q_SLOTS:
         delete q;
         QCOMPARE(p.ref_count(), 1);
     }
+
+    void SetAndGetString()
+    {
+        Properties p;
+        p.set("key", "value");
+        QVERIFY(p.get("key"));
+        QVERIFY(QString(p.get("key")) != QString(""));
+        QCOMPARE(p.get("key"), "value");
+    }
+
+    void SetAndGetInt()
+    {
+        Properties p;
+        int i = 1;
+        p.set("key", i);
+        QCOMPARE(p.get_int("key"), i);
+    }
+
+    void SetAndGetDouble()
+    {
+        Properties p;
+        double d = 1.0;
+        p.set("key", d);
+        QCOMPARE(p.get_double("key"), d);
+    }
+
+    void SetAndGetInt64()
+    {
+        Properties p;
+        qint64 i = 1LL << 32;
+        p.set("key", i);
+        QCOMPARE(p.get_int64("key"), i);
+    }
+
+    void SetAndGetData()
+    {
+        Properties p;
+        const char *value = "value";
+        char* const s = strdup(value);
+        p.set("key", s, strlen(s), free);
+        int size = 0;
+        QCOMPARE((char*) p.get_data("key", size), value);
+        QCOMPARE(size, int(strlen(value)));
+    }
+
+    void IntFromString()
+    {
+        Properties p;
+        const char *s = "-1";
+        int i = -1;
+        p.set("key", i);
+        QCOMPARE(p.get("key"), s);
+        p.set("key", s);
+        QCOMPARE(p.get_int("key"), i);
+    }
+
+    void Int64FromString()
+    {
+        Properties p;
+        const char *s = "-1";
+        qint64 i = -1;
+        p.set("key", i);
+        QCOMPARE(p.get("key"), s);
+        p.set("key", s);
+        QCOMPARE(p.get_int64("key"), i);
+    }
+
+    void DoubleFromString()
+    {
+        Properties p;
+        const char *s = "-1.234567";
+        double d = -1.234567;
+        p.set("key", d);
+        QCOMPARE(p.get("key"), s);
+        p.set("key", s);
+        QCOMPARE(p.get_double("key"), d);
+    }
+
+    void SetNullRemovesProperty()
+    {
+        Properties p;
+        const char *s = NULL;
+        p.set("key", "value");
+        p.set("key", s);
+        QCOMPARE(p.get("key"), s);
+    }
+
+    void SetAndGetHexColor()
+    {
+        Properties p;
+        const char *hexColorString = "0xaabbccdd";
+        int hexColorInt = 0xaabbccdd;
+        p.set("key", hexColorString);
+        QCOMPARE(p.get_int("key"), hexColorInt);
+    }
+
+    void SetAndGetCssColor()
+    {
+        Properties p;
+        const char *cssColorString = "#aabbcc";
+        int cssColorInt = 0xaabbccff;
+        p.set("key", cssColorString);
+        QCOMPARE(p.get_int("key"), cssColorInt);
+
+        const char *cssColorAlphaString = "#00aabbcc";
+        int cssColorAlphaInt = 0xaabbcc00;
+        p.set("key", cssColorAlphaString);
+        QCOMPARE(p.get_int("key"), cssColorAlphaInt);
+    }
+
+    void SetAndGetTimeCode()
+    {
+        Profile profile;
+        Properties p;
+        p.set("_profile", profile.get_profile(), 0);
+        const char *timeString = "11:22:33:04";
+        p.set("key", timeString);
+        QCOMPARE(p.get_int("key"), 1023829);
+        p.set("key", 1023829);
+        QCOMPARE(p.get_time("key", mlt_time_smpte), timeString);
+    }
+
+    void SetAndGetTimeClock()
+    {
+        Profile profile;
+        Properties p;
+        p.set("_profile", profile.get_profile(), 0);
+        const char *timeString = "11:22:33.400";
+        p.set("key", timeString);
+        QCOMPARE(p.get_int("key"), 1023835);
+        p.set("key", 1023835);
+        QCOMPARE(p.get_time("key", mlt_time_clock), timeString);
+    }
+
+    void SetSimpleMathExpression()
+    {
+        Properties p;
+        p.set("key", "@16.0/9.0 *2 +3 -1");
+        QCOMPARE(p.get_int("key"), 5);
+        QCOMPARE(p.get_double("key"), 16.0/9.0 *2 +3 -1);
+    }
 };
 
 QTEST_APPLESS_MAIN(TestProperties)
index 0846b085aa0e30e1a9ae3a13df925f026e389c91..cc3eb11ae6791d79a493c3dfd9ac55b23ef714cf 100644 (file)
@@ -1,4 +1,3 @@
 include (../common.pri)
 TARGET   = test_properties
 SOURCES  = test_properties.cpp
-DEFINES  += SRCDIR=\\\"$$PWD/\\\"