1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <gdk/gdk.h>
static void
test_contentformats_types (void)
{
GdkContentFormats *formats;
const char *const *mimetypes;
gsize n_types;
const GType *gtypes;
formats = gdk_content_formats_parse ("text/plain GdkFileList application/x-color GdkRGBA");
g_assert_nonnull (formats);
mimetypes = gdk_content_formats_get_mime_types (formats, &n_types);
g_assert_true (n_types == 2);
g_assert_cmpstr (mimetypes[0], ==, "text/plain");
g_assert_cmpstr (mimetypes[1], ==, "application/x-color");
gtypes = gdk_content_formats_get_gtypes (formats, &n_types);
g_assert_true (n_types == 2);
g_assert_true (gtypes[0] == GDK_TYPE_FILE_LIST);
g_assert_true (gtypes[1] == GDK_TYPE_RGBA);
gdk_content_formats_unref (formats);
}
static void
test_contentformats_union (void)
{
GdkContentFormats *formats;
GdkContentFormats *formats2;
const char *const *mimetypes;
gsize n_types;
const GType *gtypes;
formats = gdk_content_formats_parse ("text/plain application/x-color");
formats2 = gdk_content_formats_parse ("GdkFileList GdkRGBA");
formats = gdk_content_formats_union (formats, formats2);
g_assert_nonnull (formats);
mimetypes = gdk_content_formats_get_mime_types (formats, &n_types);
g_assert_true (n_types == 2);
g_assert_cmpstr (mimetypes[0], ==, "text/plain");
g_assert_cmpstr (mimetypes[1], ==, "application/x-color");
gtypes = gdk_content_formats_get_gtypes (formats, &n_types);
g_assert_true (n_types == 2);
g_assert_true (gtypes[0] == GDK_TYPE_FILE_LIST);
g_assert_true (gtypes[1] == GDK_TYPE_RGBA);
gdk_content_formats_unref (formats2);
gdk_content_formats_unref (formats);
}
int
main (int argc, char *argv[])
{
(g_test_init) (&argc, &argv, NULL);
g_type_ensure (GDK_TYPE_RGBA);
g_type_ensure (GDK_TYPE_FILE_LIST);
g_test_add_func ("/contentformats/types", test_contentformats_types);
g_test_add_func ("/contentformats/union", test_contentformats_union);
return g_test_run ();
}
|