And correct even more valid sparse warnings.
[platform/upstream/gstreamer.git] / tests / check / gst / gstutils.c
1 /* GStreamer
2  * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
3  * Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
4  *
5  * gstutils.c: Unit test for functions in gstutils
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include <gst/check/gstcheck.h>
24
25 #define SPECIAL_POINTER(x) ((void*)(19283847+(x)))
26
27 static int n_data_probes = 0;
28 static int n_buffer_probes = 0;
29 static int n_event_probes = 0;
30
31 static gboolean
32 data_probe (GstPad * pad, GstMiniObject * obj, gpointer data)
33 {
34   n_data_probes++;
35   GST_DEBUG ("data probe %d", n_data_probes);
36   g_assert (GST_IS_MINI_OBJECT (obj));
37   g_assert (data == SPECIAL_POINTER (0));
38   return TRUE;
39 }
40
41 static gboolean
42 buffer_probe (GstPad * pad, GstBuffer * obj, gpointer data)
43 {
44   n_buffer_probes++;
45   GST_DEBUG ("buffer probe %d", n_buffer_probes);
46   g_assert (GST_IS_BUFFER (obj));
47   g_assert (data == SPECIAL_POINTER (1));
48   return TRUE;
49 }
50
51 static gboolean
52 event_probe (GstPad * pad, GstEvent * obj, gpointer data)
53 {
54   n_event_probes++;
55   GST_DEBUG ("event probe %d", n_event_probes);
56   g_assert (GST_IS_EVENT (obj));
57   g_assert (data == SPECIAL_POINTER (2));
58   return TRUE;
59 }
60
61 GST_START_TEST (test_buffer_probe_n_times)
62 {
63   GstElement *pipeline, *fakesrc, *fakesink;
64   GstBus *bus;
65   GstMessage *message;
66   GstPad *pad;
67
68   pipeline = gst_element_factory_make ("pipeline", NULL);
69   fakesrc = gst_element_factory_make ("fakesrc", NULL);
70   fakesink = gst_element_factory_make ("fakesink", NULL);
71
72   g_object_set (fakesrc, "num-buffers", (int) 10, NULL);
73
74   gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
75   gst_element_link (fakesrc, fakesink);
76
77   pad = gst_element_get_pad (fakesink, "sink");
78   gst_pad_add_data_probe (pad, G_CALLBACK (data_probe), SPECIAL_POINTER (0));
79   gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe),
80       SPECIAL_POINTER (1));
81   gst_pad_add_event_probe (pad, G_CALLBACK (event_probe), SPECIAL_POINTER (2));
82   gst_object_unref (pad);
83
84   gst_element_set_state (pipeline, GST_STATE_PLAYING);
85
86   bus = gst_element_get_bus (pipeline);
87   message = gst_bus_poll (bus, GST_MESSAGE_EOS, -1);
88   gst_message_unref (message);
89   gst_object_unref (bus);
90
91   g_assert (n_buffer_probes == 10);     /* one for every buffer */
92   g_assert (n_event_probes == 2);       /* new segment and eos */
93   g_assert (n_data_probes == 12);       /* duh */
94
95   gst_element_set_state (pipeline, GST_STATE_NULL);
96   gst_object_unref (pipeline);
97
98   /* make sure nothing was sent in addition to the above when shutting down */
99   g_assert (n_buffer_probes == 10);     /* one for every buffer */
100   g_assert (n_event_probes == 2);       /* new segment and eos */
101   g_assert (n_data_probes == 12);       /* duh */
102 } GST_END_TEST;
103
104 static int n_data_probes_once = 0;
105 static int n_buffer_probes_once = 0;
106 static int n_event_probes_once = 0;
107
108 static gboolean
109 data_probe_once (GstPad * pad, GstMiniObject * obj, guint * data)
110 {
111   n_data_probes_once++;
112   g_assert (GST_IS_MINI_OBJECT (obj));
113
114   gst_pad_remove_data_probe (pad, *data);
115
116   return TRUE;
117 }
118
119 static gboolean
120 buffer_probe_once (GstPad * pad, GstBuffer * obj, guint * data)
121 {
122   n_buffer_probes_once++;
123   g_assert (GST_IS_BUFFER (obj));
124
125   gst_pad_remove_buffer_probe (pad, *data);
126
127   return TRUE;
128 }
129
130 static gboolean
131 event_probe_once (GstPad * pad, GstEvent * obj, guint * data)
132 {
133   n_event_probes_once++;
134   g_assert (GST_IS_EVENT (obj));
135
136   gst_pad_remove_event_probe (pad, *data);
137
138   return TRUE;
139 }
140
141 GST_START_TEST (test_buffer_probe_once)
142 {
143   GstElement *pipeline, *fakesrc, *fakesink;
144   GstBus *bus;
145   GstMessage *message;
146   GstPad *pad;
147   guint id1, id2, id3;
148
149   pipeline = gst_element_factory_make ("pipeline", NULL);
150   fakesrc = gst_element_factory_make ("fakesrc", NULL);
151   fakesink = gst_element_factory_make ("fakesink", NULL);
152
153   g_object_set (fakesrc, "num-buffers", (int) 10, NULL);
154
155   gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
156   gst_element_link (fakesrc, fakesink);
157
158   pad = gst_element_get_pad (fakesink, "sink");
159   id1 = gst_pad_add_data_probe (pad, G_CALLBACK (data_probe_once), &id1);
160   id2 = gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe_once), &id2);
161   id3 = gst_pad_add_event_probe (pad, G_CALLBACK (event_probe_once), &id3);
162   gst_object_unref (pad);
163
164   gst_element_set_state (pipeline, GST_STATE_PLAYING);
165
166   bus = gst_element_get_bus (pipeline);
167   message = gst_bus_poll (bus, GST_MESSAGE_EOS, -1);
168   gst_message_unref (message);
169   gst_object_unref (bus);
170
171   gst_element_set_state (pipeline, GST_STATE_NULL);
172   gst_object_unref (pipeline);
173
174   g_assert (n_buffer_probes_once == 1); /* can we hit it and quit? */
175   g_assert (n_event_probes_once == 1);  /* i said, can we hit it and quit? */
176   g_assert (n_data_probes_once == 1);   /* let's hit it and quit!!! */
177 } GST_END_TEST;
178
179 GST_START_TEST (test_math_scale)
180 {
181   fail_if (gst_util_uint64_scale_int (1, 1, 1) != 1);
182
183   fail_if (gst_util_uint64_scale_int (10, 10, 1) != 100);
184   fail_if (gst_util_uint64_scale_int (10, 10, 2) != 50);
185
186   fail_if (gst_util_uint64_scale_int (0, 10, 2) != 0);
187   fail_if (gst_util_uint64_scale_int (0, 0, 2) != 0);
188
189   fail_if (gst_util_uint64_scale_int (G_MAXUINT32, 5, 1) != G_MAXUINT32 * 5LL);
190   fail_if (gst_util_uint64_scale_int (G_MAXUINT32, 10, 2) != G_MAXUINT32 * 5LL);
191
192   fail_if (gst_util_uint64_scale_int (G_MAXUINT32, 1, 5) != G_MAXUINT32 / 5LL);
193   fail_if (gst_util_uint64_scale_int (G_MAXUINT32, 2, 10) != G_MAXUINT32 / 5LL);
194
195   /* not quite overflow */
196   fail_if (gst_util_uint64_scale_int (G_MAXUINT64 - 1, 10,
197           10) != G_MAXUINT64 - 1);
198   fail_if (gst_util_uint64_scale_int (G_MAXUINT64 - 1, G_MAXINT32,
199           G_MAXINT32) != G_MAXUINT64 - 1);
200   fail_if (gst_util_uint64_scale_int (G_MAXUINT64 - 100, G_MAXINT32,
201           G_MAXINT32) != G_MAXUINT64 - 100);
202
203   /* overflow */
204   fail_if (gst_util_uint64_scale_int (G_MAXUINT64 - 1, 10, 1) != G_MAXUINT64);
205   fail_if (gst_util_uint64_scale_int (G_MAXUINT64 - 1, G_MAXINT32,
206           1) != G_MAXUINT64);
207
208 } GST_END_TEST;
209
210 GST_START_TEST (test_math_scale_uint64)
211 {
212   fail_if (gst_util_uint64_scale (1, 1, 1) != 1);
213
214   fail_if (gst_util_uint64_scale (10, 10, 1) != 100);
215   fail_if (gst_util_uint64_scale (10, 10, 2) != 50);
216
217   fail_if (gst_util_uint64_scale (0, 10, 2) != 0);
218   fail_if (gst_util_uint64_scale (0, 0, 2) != 0);
219
220   fail_if (gst_util_uint64_scale (G_MAXUINT32, 5, 1) != G_MAXUINT32 * 5LL);
221   fail_if (gst_util_uint64_scale (G_MAXUINT32, 10, 2) != G_MAXUINT32 * 5LL);
222
223   fail_if (gst_util_uint64_scale (G_MAXUINT32, 1, 5) != G_MAXUINT32 / 5LL);
224   fail_if (gst_util_uint64_scale (G_MAXUINT32, 2, 10) != G_MAXUINT32 / 5LL);
225
226   /* not quite overflow */
227   fail_if (gst_util_uint64_scale (G_MAXUINT64 - 1, 10, 10) != G_MAXUINT64 - 1);
228   fail_if (gst_util_uint64_scale (G_MAXUINT64 - 1, G_MAXUINT32,
229           G_MAXUINT32) != G_MAXUINT64 - 1);
230   fail_if (gst_util_uint64_scale (G_MAXUINT64 - 100, G_MAXUINT32,
231           G_MAXUINT32) != G_MAXUINT64 - 100);
232
233   fail_if (gst_util_uint64_scale (G_MAXUINT64 - 1, 10, 10) != G_MAXUINT64 - 1);
234   fail_if (gst_util_uint64_scale (G_MAXUINT64 - 1, G_MAXUINT64,
235           G_MAXUINT64) != G_MAXUINT64 - 1);
236   fail_if (gst_util_uint64_scale (G_MAXUINT64 - 100, G_MAXUINT64,
237           G_MAXUINT64) != G_MAXUINT64 - 100);
238
239   /* overflow */
240   fail_if (gst_util_uint64_scale (G_MAXUINT64 - 1, 10, 1) != G_MAXUINT64);
241   fail_if (gst_util_uint64_scale (G_MAXUINT64 - 1, G_MAXUINT64,
242           1) != G_MAXUINT64);
243
244 } GST_END_TEST;
245
246 GST_START_TEST (test_math_scale_random)
247 {
248   guint64 val, num, denom, res;
249   GRand *rand;
250   gint i;
251
252   rand = g_rand_new ();
253
254   i = 100000;
255   while (i--) {
256     guint64 check, diff;
257
258     val = ((guint64) g_rand_int (rand)) << 32 | g_rand_int (rand);
259     num = ((guint64) g_rand_int (rand)) << 32 | g_rand_int (rand);
260     denom = ((guint64) g_rand_int (rand)) << 32 | g_rand_int (rand);
261
262     res = gst_util_uint64_scale (val, num, denom);
263     check = gst_gdouble_to_guint64 (gst_guint64_to_gdouble (val) *
264         gst_guint64_to_gdouble (num) / gst_guint64_to_gdouble (denom));
265
266     if (res < G_MAXUINT64 && check < G_MAXUINT64) {
267       if (res > check)
268         diff = res - check;
269       else
270         diff = check - res;
271
272       /* some arbitrary value, really.. someone do the proper math to get
273        * the upper bound */
274       if (diff > 20000)
275         fail_if (diff > 20000);
276     }
277   }
278   g_rand_free (rand);
279
280 }
281
282 GST_END_TEST;
283
284 GST_START_TEST (test_guint64_to_gdouble)
285 {
286   guint64 from[] = { 0, 1, 100, 10000, (guint64) (1) << 63,
287     ((guint64) (1) << 63) + 1,
288     ((guint64) (1) << 63) + (G_GINT64_CONSTANT (1) << 62)
289   };
290   gdouble to[] = { 0., 1., 100., 10000., 9223372036854775808.,
291     9223372036854775809., 13835058055282163712.
292   };
293   gdouble tolerance[] = { 0., 0., 0., 0., 0., 1., 1. };
294   gint i;
295   gdouble result;
296   gdouble delta;
297
298   for (i = 0; i < G_N_ELEMENTS (from); ++i) {
299     result = gst_util_guint64_to_gdouble (from[i]);
300     delta = ABS (to[i] - result);
301     fail_unless (delta <= tolerance[i],
302         "Could not convert %d: %" G_GUINT64_FORMAT
303         " -> %f, got %f instead, delta of %e with tolerance of %e",
304         i, from[i], to[i], result, delta, tolerance[i]);
305   }
306 }
307
308 GST_END_TEST;
309
310 GST_START_TEST (test_gdouble_to_guint64)
311 {
312   gdouble from[] = { 0., 1., 100., 10000., 9223372036854775808.,
313     9223372036854775809., 13835058055282163712.
314   };
315   guint64 to[] = { 0, 1, 100, 10000, (guint64) (1) << 63,
316     ((guint64) (1) << 63) + 1,
317     ((guint64) (1) << 63) + (G_GINT64_CONSTANT (1) << 62)
318   };
319   guint64 tolerance[] = { 0, 0, 0, 0, 0, 1, 1 };
320   gint i;
321   gdouble result;
322   guint64 delta;
323
324   for (i = 0; i < G_N_ELEMENTS (from); ++i) {
325     result = gst_util_gdouble_to_guint64 (from[i]);
326     delta = ABS (to[i] - result);
327     fail_unless (delta <= tolerance[i],
328         "Could not convert %f: %" G_GUINT64_FORMAT
329         " -> %d, got %d instead, delta of %e with tolerance of %e",
330         i, from[i], to[i], result, delta, tolerance[i]);
331   }
332 }
333
334 GST_END_TEST;
335
336 #ifndef GST_DISABLE_PARSE
337 GST_START_TEST (test_parse_bin_from_description)
338 {
339   struct
340   {
341     const gchar *bin_desc;
342     const gchar *pad_names;
343   } bin_tests[] = {
344     {
345     "identity", "identity0/sink,identity0/src"}, {
346     "identity ! identity ! identity", "identity1/sink,identity3/src"}, {
347     "identity ! fakesink", "identity4/sink"}, {
348     "fakesrc ! identity", "identity5/src"}, {
349     "fakesrc ! fakesink", ""}
350   };
351   gint i;
352
353   for (i = 0; i < G_N_ELEMENTS (bin_tests); ++i) {
354     GstElement *bin, *parent;
355     GString *s;
356     GstPad *ghost_pad, *target_pad;
357     GError *err = NULL;
358
359     bin = gst_parse_bin_from_description (bin_tests[i].bin_desc, TRUE, &err);
360     if (err) {
361       g_error ("ERROR in gst_parse_bin_from_description (%s): %s",
362           bin_tests[i].bin_desc, err->message);
363     }
364     g_assert (bin != NULL);
365
366     s = g_string_new ("");
367     if ((ghost_pad = gst_element_get_pad (bin, "sink"))) {
368       g_assert (GST_IS_GHOST_PAD (ghost_pad));
369
370       target_pad = gst_ghost_pad_get_target (GST_GHOST_PAD (ghost_pad));
371       g_assert (target_pad != NULL);
372       g_assert (GST_IS_PAD (target_pad));
373
374       parent = gst_pad_get_parent_element (target_pad);
375       g_assert (parent != NULL);
376
377       g_string_append_printf (s, "%s/sink", GST_ELEMENT_NAME (parent));
378
379       gst_object_unref (parent);
380       gst_object_unref (target_pad);
381       gst_object_unref (ghost_pad);
382     }
383
384     if ((ghost_pad = gst_element_get_pad (bin, "src"))) {
385       g_assert (GST_IS_GHOST_PAD (ghost_pad));
386
387       target_pad = gst_ghost_pad_get_target (GST_GHOST_PAD (ghost_pad));
388       g_assert (target_pad != NULL);
389       g_assert (GST_IS_PAD (target_pad));
390
391       parent = gst_pad_get_parent_element (target_pad);
392       g_assert (parent != NULL);
393
394       if (s->len > 0) {
395         g_string_append (s, ",");
396       }
397
398       g_string_append_printf (s, "%s/src", GST_ELEMENT_NAME (parent));
399
400       gst_object_unref (parent);
401       gst_object_unref (target_pad);
402       gst_object_unref (ghost_pad);
403     }
404
405     if (strcmp (s->str, bin_tests[i].pad_names) != 0) {
406       g_error ("FAILED: expted '%s', got '%s' for bin '%s'",
407           bin_tests[i].pad_names, s->str, bin_tests[i].bin_desc);
408     }
409     g_string_free (s, TRUE);
410
411     gst_object_unref (bin);
412   }
413 }
414
415 GST_END_TEST;
416 #endif
417
418 GST_START_TEST (test_element_found_tags)
419 {
420   GstElement *pipeline, *fakesrc, *fakesink;
421   GstTagList *list;
422   GstBus *bus;
423   GstMessage *message;
424
425   pipeline = gst_element_factory_make ("pipeline", NULL);
426   fakesrc = gst_element_factory_make ("fakesrc", NULL);
427   fakesink = gst_element_factory_make ("fakesink", NULL);
428   list = gst_tag_list_new ();
429
430   g_object_set (fakesrc, "num-buffers", (int) 10, NULL);
431
432   gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
433   gst_element_link (fakesrc, fakesink);
434
435   gst_element_set_state (pipeline, GST_STATE_PLAYING);
436
437   gst_element_found_tags (GST_ELEMENT (fakesrc), list);
438
439   bus = gst_element_get_bus (pipeline);
440   message = gst_bus_poll (bus, GST_MESSAGE_EOS, -1);
441   gst_message_unref (message);
442   gst_object_unref (bus);
443
444   /* FIXME: maybe also check if the fakesink receives the message */
445
446   gst_element_set_state (pipeline, GST_STATE_NULL);
447   gst_object_unref (pipeline);
448 }
449
450 GST_END_TEST;
451
452 GST_START_TEST (test_element_unlink)
453 {
454   GstElement *src, *sink;
455
456   src = gst_element_factory_make ("fakesrc", NULL);
457   sink = gst_element_factory_make ("fakesink", NULL);
458   fail_unless (gst_element_link (src, sink) != FALSE);
459   gst_element_unlink (src, sink);
460   gst_object_unref (src);
461   gst_object_unref (sink);
462 }
463
464 GST_END_TEST;
465
466 GST_START_TEST (test_set_value_from_string)
467 {
468   GValue val = { 0, };
469
470   /* g_return_if_fail */
471   ASSERT_CRITICAL (gst_util_set_value_from_string (NULL, "xyz"));
472
473   g_value_init (&val, G_TYPE_STRING);
474   ASSERT_CRITICAL (gst_util_set_value_from_string (&val, NULL));
475   g_value_unset (&val);
476
477   /* string => string */
478   g_value_init (&val, G_TYPE_STRING);
479   gst_util_set_value_from_string (&val, "Y00");
480   fail_unless (g_value_get_string (&val) != NULL);
481   fail_unless_equals_string (g_value_get_string (&val), "Y00");
482   g_value_unset (&val);
483
484   /* string => int */
485   g_value_init (&val, G_TYPE_INT);
486   gst_util_set_value_from_string (&val, "987654321");
487   fail_unless (g_value_get_int (&val) == 987654321);
488   g_value_unset (&val);
489
490   g_value_init (&val, G_TYPE_INT);
491   ASSERT_CRITICAL (gst_util_set_value_from_string (&val, "xyz"));
492   g_value_unset (&val);
493
494   /* string => uint */
495   g_value_init (&val, G_TYPE_UINT);
496   gst_util_set_value_from_string (&val, "987654321");
497   fail_unless (g_value_get_uint (&val) == 987654321);
498   g_value_unset (&val);
499
500   /* CHECKME: is this really desired behaviour? (tpm) */
501   g_value_init (&val, G_TYPE_UINT);
502   gst_util_set_value_from_string (&val, "-999");
503   fail_unless (g_value_get_uint (&val) == ((guint) 0 - (guint) 999));
504   g_value_unset (&val);
505
506   g_value_init (&val, G_TYPE_UINT);
507   ASSERT_CRITICAL (gst_util_set_value_from_string (&val, "xyz"));
508   g_value_unset (&val);
509
510   /* string => long */
511   g_value_init (&val, G_TYPE_LONG);
512   gst_util_set_value_from_string (&val, "987654321");
513   fail_unless (g_value_get_long (&val) == 987654321);
514   g_value_unset (&val);
515
516   g_value_init (&val, G_TYPE_LONG);
517   ASSERT_CRITICAL (gst_util_set_value_from_string (&val, "xyz"));
518   g_value_unset (&val);
519
520   /* string => ulong */
521   g_value_init (&val, G_TYPE_ULONG);
522   gst_util_set_value_from_string (&val, "987654321");
523   fail_unless (g_value_get_ulong (&val) == 987654321);
524   g_value_unset (&val);
525
526   /* CHECKME: is this really desired behaviour? (tpm) */
527   g_value_init (&val, G_TYPE_ULONG);
528   gst_util_set_value_from_string (&val, "-999");
529   fail_unless (g_value_get_ulong (&val) == ((gulong) 0 - (gulong) 999));
530   g_value_unset (&val);
531
532   g_value_init (&val, G_TYPE_ULONG);
533   ASSERT_CRITICAL (gst_util_set_value_from_string (&val, "xyz"));
534   g_value_unset (&val);
535
536   /* string => boolean */
537   g_value_init (&val, G_TYPE_BOOLEAN);
538   gst_util_set_value_from_string (&val, "true");
539   fail_unless_equals_int (g_value_get_boolean (&val), TRUE);
540   g_value_unset (&val);
541
542   g_value_init (&val, G_TYPE_BOOLEAN);
543   gst_util_set_value_from_string (&val, "TRUE");
544   fail_unless_equals_int (g_value_get_boolean (&val), TRUE);
545   g_value_unset (&val);
546
547   g_value_init (&val, G_TYPE_BOOLEAN);
548   gst_util_set_value_from_string (&val, "false");
549   fail_unless_equals_int (g_value_get_boolean (&val), FALSE);
550   g_value_unset (&val);
551
552   g_value_init (&val, G_TYPE_BOOLEAN);
553   gst_util_set_value_from_string (&val, "FALSE");
554   fail_unless_equals_int (g_value_get_boolean (&val), FALSE);
555   g_value_unset (&val);
556
557   g_value_init (&val, G_TYPE_BOOLEAN);
558   gst_util_set_value_from_string (&val, "bleh");
559   fail_unless_equals_int (g_value_get_boolean (&val), FALSE);
560   g_value_unset (&val);
561
562 #if 0
563   /* string => float (yay, localisation issues involved) */
564   g_value_init (&val, G_TYPE_FLOAT);
565   gst_util_set_value_from_string (&val, "987.654");
566   fail_unless (g_value_get_float (&val) >= 987.653 &&
567       g_value_get_float (&val) <= 987.655);
568   g_value_unset (&val);
569
570   g_value_init (&val, G_TYPE_FLOAT);
571   gst_util_set_value_from_string (&val, "987,654");
572   fail_unless (g_value_get_float (&val) >= 987.653 &&
573       g_value_get_float (&val) <= 987.655);
574   g_value_unset (&val);
575
576   /* string => double (yay, localisation issues involved) */
577   g_value_init (&val, G_TYPE_DOUBLE);
578   gst_util_set_value_from_string (&val, "987.654");
579   fail_unless (g_value_get_double (&val) >= 987.653 &&
580       g_value_get_double (&val) <= 987.655);
581   g_value_unset (&val);
582
583   g_value_init (&val, G_TYPE_DOUBLE);
584   gst_util_set_value_from_string (&val, "987,654");
585   fail_unless (g_value_get_double (&val) >= 987.653 &&
586       g_value_get_double (&val) <= 987.655);
587   g_value_unset (&val);
588 #endif
589 }
590
591 GST_END_TEST;
592
593 static Suite *
594 gst_utils_suite (void)
595 {
596   Suite *s = suite_create ("GstUtils");
597   TCase *tc_chain = tcase_create ("general");
598
599   suite_add_tcase (s, tc_chain);
600   tcase_add_test (tc_chain, test_buffer_probe_n_times);
601   tcase_add_test (tc_chain, test_buffer_probe_once);
602   tcase_add_test (tc_chain, test_math_scale);
603   tcase_add_test (tc_chain, test_math_scale_uint64);
604   tcase_add_test (tc_chain, test_math_scale_random);
605   tcase_add_test (tc_chain, test_guint64_to_gdouble);
606   tcase_add_test (tc_chain, test_gdouble_to_guint64);
607 #ifndef GST_DISABLE_PARSE
608   tcase_add_test (tc_chain, test_parse_bin_from_description);
609 #endif
610   tcase_add_test (tc_chain, test_element_found_tags);
611   tcase_add_test (tc_chain, test_element_unlink);
612   tcase_add_test (tc_chain, test_set_value_from_string);
613   return s;
614 }
615
616 GST_CHECK_MAIN (gst_utils);