source: trunk/third/gstreamer/testsuite/caps/value_compare.c @ 21005

Revision 21005, 3.7 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
RevLine 
[21004]1
2#include <gst/gst.h>
3#include <glib.h>
4
5void
6test1 (void)
7{
8  GValue value1 = { 0 };
9  GValue value2 = { 0 };
10
11  //GValue value3 = { 0 };
12  //gboolean ret;
13
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);
23
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);
33
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);
43
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);
52
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);
63
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);
74
75  /* comparing 10/100 with 200/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);
83
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);
94
95}
96
97int
98main (int argc, char *argv[])
99{
100
101  gst_init (&argc, &argv);
102
103  test1 ();
104
105  return 0;
106}
Note: See TracBrowser for help on using the repository browser.