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)