[gstreamermm: 106/167] added tests for Structure, additional test in TagList



commit 1b7aa886b229423937c48a964d52fe18a393836f
Author: Marcin Kolny [loganek] <marcin kolny gmail com>
Date:   Thu Aug 1 02:16:39 2013 +0200

    added tests for Structure, additional test in TagList

 tests/test-structure.cc |   85 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/test-taglist.cc   |   10 +++++
 2 files changed, 95 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-structure.cc b/tests/test-structure.cc
new file mode 100644
index 0000000..d7e3520
--- /dev/null
+++ b/tests/test-structure.cc
@@ -0,0 +1,85 @@
+/*
+ * test-structure.cc
+ *
+ *  Created on: 1 sie 2013
+ *      Author: loganek
+ */
+
+
+#include <gtest/gtest.h>
+#include <gstreamermm.h>
+
+using namespace Gst;
+
+template<typename T>
+void CheckEq(const T& expected, const T& output)
+{
+    EXPECT_EQ(expected, output);
+}
+
+template<>
+void CheckEq(const Fraction& expected, const Fraction& output)
+{
+    EXPECT_EQ(expected.denom, output.denom);
+    EXPECT_EQ(expected.num, output.num);
+}
+
+template<>
+void CheckEq(const FractionRange& expected, const FractionRange& output)
+{
+    CheckEq(expected.min, output.min);
+    CheckEq(expected.max, output.max);
+}
+
+class StructureTest : public ::testing::Test
+{
+protected:
+    Structure structure = Structure("test-struct");
+
+    template<typename T>
+    void CheckGetSetField(const T& expected, const Glib::ustring& field_name)
+    {
+        structure.set_field(field_name, expected);
+
+        T output;
+        structure.get_field(field_name, output);
+
+        CheckEq(expected, output);
+    }
+};
+
+TEST_F(StructureTest, GetSetStringVariable)
+{
+    CheckGetSetField<std::string>("this is simple test", "string");
+}
+
+TEST_F(StructureTest, GetSetIntegerVariable)
+{
+    CheckGetSetField(1234, "integer");
+}
+
+TEST_F(StructureTest, GetSetFractionVariable)
+{
+    CheckGetSetField(Fraction(5,6), "fraction");
+}
+
+TEST_F(StructureTest, GetSetFractionRangeVariable)
+{
+    CheckGetSetField(FractionRange(Fraction(5,6), Gst::Fraction(13,14)), "fraction_range");
+}
+
+TEST_F(StructureTest, GetSetDateVariable)
+{
+    CheckGetSetField(Glib::Date(10, Glib::Date::DECEMBER, 1991), "date");
+}
+
+TEST_F(StructureTest, GetSetEnumVariable)
+{
+    State input_state = STATE_PAUSED;
+    structure.set_field("state", Glib::Value<State>::value_type(), input_state);
+
+    int output_state;
+    structure.get_field("state", Glib::Value<State>::value_type(), output_state);
+
+    EXPECT_EQ(input_state, (State)output_state);
+}
diff --git a/tests/test-taglist.cc b/tests/test-taglist.cc
index 89d0d4d..03ec864 100644
--- a/tests/test-taglist.cc
+++ b/tests/test-taglist.cc
@@ -74,3 +74,13 @@ TEST_F(TagListTest, GetTagDateFromList)
     EXPECT_EQ(song_date.get_year(), out_date.get_year());
     EXPECT_EQ(song_date.get_month(), out_date.get_month());
 }
+
+TEST_F(TagListTest, GetNonExistingTag)
+{
+       Glib::ustring album;
+
+    bool album_exists = tag_list.get(TAG_ALBUM, album);
+
+    ASSERT_FALSE(album_exists);
+
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]