11 //GValue value3 = { 0 };
14 g_value_init (&value1, G_TYPE_INT);
15 g_value_set_int (&value1, 10);
16 g_value_init (&value2, G_TYPE_INT);
17 g_value_set_int (&value2, 20);
18 g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
19 g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
20 g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
21 g_value_unset (&value1);
22 g_value_unset (&value2);
24 g_value_init (&value1, G_TYPE_DOUBLE);
25 g_value_set_double (&value1, 10);
26 g_value_init (&value2, G_TYPE_DOUBLE);
27 g_value_set_double (&value2, 20);
28 g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
29 g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
30 g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
31 g_value_unset (&value1);
32 g_value_unset (&value2);
34 g_value_init (&value1, G_TYPE_STRING);
35 g_value_set_string (&value1, "a");
36 g_value_init (&value2, G_TYPE_STRING);
37 g_value_set_string (&value2, "b");
38 g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
39 g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
40 g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
41 g_value_unset (&value1);
42 g_value_unset (&value2);
44 g_value_init (&value1, GST_TYPE_FOURCC);
45 gst_value_set_fourcc (&value1, GST_MAKE_FOURCC ('a', 'b', 'c', 'd'));
46 g_value_init (&value2, GST_TYPE_FOURCC);
47 gst_value_set_fourcc (&value2, GST_MAKE_FOURCC ('1', '2', '3', '4'));
48 g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_UNORDERED);
49 g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
50 g_value_unset (&value1);
51 g_value_unset (&value2);
53 /* comparing 2/3 with 3/4 */
54 g_value_init (&value1, GST_TYPE_FRACTION);
55 gst_value_set_fraction (&value1, 2, 3);
56 g_value_init (&value2, GST_TYPE_FRACTION);
57 gst_value_set_fraction (&value2, 3, 4);
58 g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
59 g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
60 g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
61 g_value_unset (&value1);
62 g_value_unset (&value2);
64 /* comparing -4/5 with 2/-3 */
65 g_value_init (&value1, GST_TYPE_FRACTION);
66 gst_value_set_fraction (&value1, -4, 5);
67 g_value_init (&value2, GST_TYPE_FRACTION);
68 gst_value_set_fraction (&value2, 2, -3);
69 g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
70 g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
71 g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
72 g_value_unset (&value1);
73 g_value_unset (&value2);
75 /* comparing 10/100 with 20/2000 */
76 g_value_init (&value1, GST_TYPE_FRACTION);
77 gst_value_set_fraction (&value1, 10, 100);
78 g_value_init (&value2, GST_TYPE_FRACTION);
79 gst_value_set_fraction (&value2, 200, 2000);
80 g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_EQUAL);
81 g_value_unset (&value1);
82 g_value_unset (&value2);
84 /* comparing -4/5 with 2/-3 */
85 g_value_init (&value1, GST_TYPE_FRACTION);
86 gst_value_set_fraction (&value1, -4, 5);
87 g_value_init (&value2, GST_TYPE_FRACTION);
88 gst_value_set_fraction (&value2, 2, -3);
89 g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN);
90 g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN);
91 g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
92 g_value_unset (&value1);
93 g_value_unset (&value2);
98 main (int argc, char *argv[])
101 gst_init (&argc, &argv);