[gstreamermm] Gst::Caps: remove unused template parameter, add one more test



commit dfceed9f3e6f364f245be6ef6854b1569bc2fec9
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Thu Aug 27 15:57:41 2015 +0000

    Gst::Caps: remove unused template parameter, add one more test
    
        * gstreamer/src/caps.hg: anonymous template parameter is unused inside
          function set_simple() so it has been removed.
        * tests/test-caps.cc: add test which checks auto-registration custom
          types on add it to a caps structure.

 gstreamer/src/caps.hg |    8 ++++----
 tests/test-caps.cc    |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/gstreamer/src/caps.hg b/gstreamer/src/caps.hg
index a942149..47cfac2 100644
--- a/gstreamer/src/caps.hg
+++ b/gstreamer/src/caps.hg
@@ -175,8 +175,8 @@ public:
    * supported C++ type).
    * @param ...further_data further data to set in format: name, data.
    */
-  template<class = Glib::ustring, class DataType, class ...T>
-  void set_simple(const Glib::ustring & name, const DataType& data, T ...further_data);
+  template<class DataType, class ...DataTypes>
+  void set_simple(const Glib::ustring & name, const DataType& data, DataTypes ...further_data);
 
   /** Sets fields in a simple Gst::Caps. A simple Gst::Caps is one that only
    * has one structure.
@@ -279,8 +279,8 @@ private:
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 
-template<class, class DataType, class ...T>
-void Caps::set_simple(const Glib::ustring & name, const DataType& data, T ...further_data)
+template<class DataType, class ...DataTypes>
+void Caps::set_simple(const Glib::ustring & name, const DataType& data, DataTypes ...further_data)
 {
   this->set_value(name, data);
   this->set_simple(further_data...);
diff --git a/tests/test-caps.cc b/tests/test-caps.cc
index 2ff5c59..d2b6a1d 100644
--- a/tests/test-caps.cc
+++ b/tests/test-caps.cc
@@ -151,3 +151,39 @@ TEST_F(CapsTest, SetSimpleWithManyParameters)
   CheckCaps("framerate", framerate);
   CheckCaps<std::string>("test-data", "test-value");
 }
+
+class CapsTestDummy1
+{
+public:
+       int a = 0;
+       std::string b;
+       CapsTestDummy1(int a, std::string b) : a(a), b(b) {}
+       CapsTestDummy1() {}
+};
+class CapsTestDummy2
+{
+public:
+       char c = 0;
+       CapsTestDummy2(char c) : c(c) {}
+       CapsTestDummy2() {}
+};
+
+
+TEST_F(CapsTest, CreateWithManyCustomTypeParameters)
+{
+  caps = Caps::create_simple("video/x-raw");
+  caps->set_simple("d1", CapsTestDummy1(1, "dummy1"), "d2", CapsTestDummy2('x'), "d3", CapsTestDummy1(63, 
"dummy3"));
+  Glib::Value<CapsTestDummy1> d1, d3;
+  Glib::Value<CapsTestDummy2> d2;
+  caps->get_structure(0).get_field("d1", d1);
+  caps->get_structure(0).get_field("d2", d2);
+  caps->get_structure(0).get_field("d3", d3);
+
+  ASSERT_STREQ("dummy1", d1.get().b.c_str());
+  ASSERT_EQ(1, d1.get().a);
+
+  ASSERT_EQ('x', d2.get().c);
+
+  ASSERT_STREQ("dummy3", d3.get().b.c_str());
+  ASSERT_EQ(63, d3.get().a);
+}


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