diff --git a/ChangeLog b/ChangeLog index d22708ad35..6aee5291f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +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): diff --git a/check/gst/gstcaps.c b/check/gst/gstcaps.c index 9141fceb8c..a162cc3e46 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 9141fceb8c..a162cc3e46 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; }