]> git.sesse.net Git - mlt/blobdiff - src/tests/test_properties/test_properties.cpp
Add mlt_property_get_double_pos() and mlt_property_get_int_pos().
[mlt] / src / tests / test_properties / test_properties.cpp
index b8eb494cbd6c1eaab07ab71ee6d385b947b8d4b9..b0bd50a9005926becc5fcce9e5af09a75ad8b62b 100644 (file)
@@ -521,6 +521,48 @@ private Q_SLOTS:
         mlt_property_close(item.property);
         mlt_animation_close(a);
     }
+
+    void test_property_get_double_pos()
+    {
+        locale_t locale;
+#if defined(__linux__) || defined(__DARWIN__)
+        locale = newlocale( LC_NUMERIC_MASK, "POSIX", NULL );
+#endif
+        double fps = 25.0;
+        mlt_property p = mlt_property_init();
+        mlt_property_set_string(p, "10=100; 20=200");
+        QCOMPARE(mlt_property_get_double(p, fps, locale), 10.0);
+        QCOMPARE(mlt_property_get_double_pos(p, fps, locale, 0, 100), 100.0);
+        QCOMPARE(mlt_property_get_double_pos(p, fps, locale, 15, 100), 150.0);
+        QCOMPARE(mlt_property_get_double_pos(p, fps, locale, 20, 100), 200.0);
+
+        mlt_property_set_string(p, "1.5");
+        QCOMPARE(mlt_property_get_double(p, fps, locale), 1.5);
+        QCOMPARE(mlt_property_get_double_pos(p, fps, locale, 10, 100), 1.5);
+
+        mlt_property_close(p);
+    }
+
+    void test_property_get_int_pos()
+    {
+        locale_t locale;
+#if defined(__linux__) || defined(__DARWIN__)
+        locale = newlocale( LC_NUMERIC_MASK, "POSIX", NULL );
+#endif
+        double fps = 25.0;
+        mlt_property p = mlt_property_init();
+        mlt_property_set_string(p, "10=100; 20=200");
+        QCOMPARE(mlt_property_get_int(p, fps, locale), 10);
+        QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 0, 100), 100);
+        QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 15, 100), 150);
+        QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 20, 100), 200);
+
+        mlt_property_set_string(p, "1.5");
+        QCOMPARE(mlt_property_get_int(p, fps, locale), 1);
+        QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 10, 100), 1);
+
+        mlt_property_close(p);
+    }
 };
 
 QTEST_APPLESS_MAIN(TestProperties)