From 7b4a9e4c582d5d3956a697d614012b8f42ea188f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 22 Aug 2005 15:08:44 +0000 Subject: [PATCH] check/gst/gstcaps.c: Added check for gst_static_caps_get() refcounting. Original commit message from CVS: * check/gst/gstcaps.c: (GST_START_TEST), (gst_caps_suite): Added check for gst_static_caps_get() refcounting. --- ChangeLog | 5 +++++ check/gst/gstcaps.c | 28 ++++++++++++++++++++++++++++ tests/check/gst/gstcaps.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/ChangeLog b/ChangeLog index d22708a..6aee529 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-08-22 Wim Taymans + * check/gst/gstcaps.c: (GST_START_TEST), (gst_caps_suite): + Added check for gst_static_caps_get() refcounting. + +2005-08-22 Wim Taymans + * gst/gstcaps.c: (gst_static_caps_get), (gst_caps_to_string): Make _static_caps_get() refcounting sane. diff --git a/check/gst/gstcaps.c b/check/gst/gstcaps.c index 9141fce..a162cc3 100644 --- a/check/gst/gstcaps.c +++ b/check/gst/gstcaps.c @@ -97,6 +97,32 @@ GST_START_TEST (test_mutability) GST_END_TEST; +GST_START_TEST (test_static_caps) +{ + GstStaticCaps scaps = GST_STATIC_CAPS ("audio/x-raw-int,rate=44100"); + GstCaps *caps1; + GstCaps *caps2; + + /* caps creation */ + caps1 = gst_static_caps_get (&scaps); + fail_unless (caps1 != NULL); + /* 1 refcount core, one from us */ + fail_unless (GST_CAPS_REFCOUNT (caps1) == 2); + + /* caps should be the same */ + caps2 = gst_static_caps_get (&scaps); + fail_unless (caps2 != NULL); + /* 1 refcount core, two from us */ + fail_unless (GST_CAPS_REFCOUNT (caps1) == 3); + /* caps must be equal */ + fail_unless (caps1 == caps2); + + gst_caps_unref (caps1); + gst_caps_unref (caps2); +} + +GST_END_TEST; + Suite * gst_caps_suite (void) { @@ -108,6 +134,8 @@ gst_caps_suite (void) tcase_add_test (tc_chain, test_double_append); tcase_add_test (tc_chain, test_mutability); tcase_add_test (tc_chain, test_buffer); + tcase_add_test (tc_chain, test_static_caps); + return s; } diff --git a/tests/check/gst/gstcaps.c b/tests/check/gst/gstcaps.c index 9141fce..a162cc3 100644 --- a/tests/check/gst/gstcaps.c +++ b/tests/check/gst/gstcaps.c @@ -97,6 +97,32 @@ GST_START_TEST (test_mutability) GST_END_TEST; +GST_START_TEST (test_static_caps) +{ + GstStaticCaps scaps = GST_STATIC_CAPS ("audio/x-raw-int,rate=44100"); + GstCaps *caps1; + GstCaps *caps2; + + /* caps creation */ + caps1 = gst_static_caps_get (&scaps); + fail_unless (caps1 != NULL); + /* 1 refcount core, one from us */ + fail_unless (GST_CAPS_REFCOUNT (caps1) == 2); + + /* caps should be the same */ + caps2 = gst_static_caps_get (&scaps); + fail_unless (caps2 != NULL); + /* 1 refcount core, two from us */ + fail_unless (GST_CAPS_REFCOUNT (caps1) == 3); + /* caps must be equal */ + fail_unless (caps1 == caps2); + + gst_caps_unref (caps1); + gst_caps_unref (caps2); +} + +GST_END_TEST; + Suite * gst_caps_suite (void) { @@ -108,6 +134,8 @@ gst_caps_suite (void) tcase_add_test (tc_chain, test_double_append); tcase_add_test (tc_chain, test_mutability); tcase_add_test (tc_chain, test_buffer); + tcase_add_test (tc_chain, test_static_caps); + return s; } -- 2.7.4