libpurple/tests/test_image.c

Mon, 12 May 2025 20:25:16 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 12 May 2025 20:25:16 -0500
changeset 43246
0e9bbe9b4da8
parent 42866
4b201e18638f
permissions
-rw-r--r--

Handle formatting in server messages

Testing Done:
Used the default motd on my local ergo server to verify that formatting was working.

Reviewed at https://reviews.imfreedom.org/r/3991/

38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * numerous to list here. Please refer to the COPYRIGHT file distributed
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * with this source distribution
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or (at
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * your option) any later version.
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * General Public License for more details.
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib.h>
38426
e35d277efcce tests: Add missing string.h includes
Mike Ruprecht <cmaiku@gmail.com>
parents: 38286
diff changeset
24 #include <string.h>
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 #include <purple.h>
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 // generated via:
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 // $ cat test-image.png | hexdump -v -e '1 1 "0x%02x," " "' | xargs -n 8 echo
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 static const gsize test_image_data_len = 160;
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 static const guint8 test_image_data[] = {
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 0x08, 0x02, 0x00, 0x00, 0x00, 0xfd, 0xd4, 0x9a,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 0x73, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45, 0x07, 0xe0,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 0x0a, 0x02, 0x16, 0x30, 0x22, 0x28, 0xa4, 0xc9,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 0xdd, 0x00, 0x00, 0x00, 0x1d, 0x69, 0x54, 0x58,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x72, 0x65,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x64, 0x2e,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 0x65, 0x07, 0x00, 0x00, 0x00, 0x16, 0x49, 0x44,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 0x41, 0x54, 0x08, 0xd7, 0x63, 0xf8, 0xff, 0xff,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 0x3f, 0x03, 0x03, 0x03, 0xe3, 0xb3, 0x4c, 0xb5,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 0x9b, 0x4e, 0x0b, 0x00, 0x2f, 0xa9, 0x06, 0x2f,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 0x8a, 0xd1, 0xc6, 0xb3, 0x00, 0x00, 0x00, 0x00,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 };
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 /******************************************************************************
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 * Helpers
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 *****************************************************************************/
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 static void
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 _test_image(PurpleImage *image,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 const guint8 *edata,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 gsize elen,
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
61 const char *path,
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
62 const char *ext,
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
63 const char *mimetype)
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 {
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 GBytes *bytes = NULL;
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 const guint8 *adata = NULL;
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 gsize alen;
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 g_assert(PURPLE_IS_IMAGE(image));
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 bytes = purple_image_get_contents(image);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 adata = g_bytes_get_data(bytes, &alen);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 g_assert_cmpmem(adata, alen, edata, elen);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 g_bytes_unref(bytes);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
38568
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
76 /* if the caller provided a path, check it, otherwise just make sure we
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
77 * have something.
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
78 */
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
79 if(path != NULL) {
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
80 g_assert_cmpstr(purple_image_get_path(image), ==, path);
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
81 } else {
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
82 const char *apath = purple_image_get_path(image);
38573
e890b91f60fe Use g_test_set_nonfatal_assertions when available
Gary Kramlich <grim@reaperworld.com>
parents: 38570
diff changeset
83
e890b91f60fe Use g_test_set_nonfatal_assertions when available
Gary Kramlich <grim@reaperworld.com>
parents: 38570
diff changeset
84 g_assert(apath);
e890b91f60fe Use g_test_set_nonfatal_assertions when available
Gary Kramlich <grim@reaperworld.com>
parents: 38570
diff changeset
85 g_assert_cmpstr(apath, !=, "");
38568
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
86 }
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
87
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 g_assert_cmpstr(purple_image_get_extension(image), ==, ext);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 g_assert_cmpstr(purple_image_get_mimetype(image), ==, mimetype);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
42592
6b65c0e4ba15 Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
91 g_object_unref(image);
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 }
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
38568
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
94 /******************************************************************************
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
95 * Tests
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
96 *****************************************************************************/
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
97 static void
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
98 test_image_new_from_bytes(void) {
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
99 GBytes *bytes = g_bytes_new(test_image_data, test_image_data_len);
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
100 PurpleImage *image = purple_image_new_from_bytes(bytes);
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
101
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
102 _test_image(
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
103 image,
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
104 g_bytes_get_data(bytes, NULL),
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
105 g_bytes_get_size(bytes),
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
106 NULL,
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
107 "png",
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
108 "image/png"
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
109 );
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
110
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
111 g_bytes_unref(bytes);
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
112 }
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
113
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
114
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 static void
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 test_image_new_from_data(void) {
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 PurpleImage *image = purple_image_new_from_data(
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 test_image_data,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 test_image_data_len
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 );
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 _test_image(
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 image,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 test_image_data,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 test_image_data_len,
38568
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
126 NULL,
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 "png",
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 "image/png"
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 );
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 }
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 static void
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 test_image_new_from_file(void) {
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 PurpleImage *image = NULL;
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 GError *error = NULL;
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
136 char *path = NULL;
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
137 char *edata = NULL;
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 gsize elen;
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 path = g_build_filename(TEST_DATA_DIR, "test-image.png", NULL);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 image = purple_image_new_from_file(path, &error);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 g_assert_no_error(error);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 g_file_get_contents(path, &edata, &elen, &error);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 g_assert_no_error(error);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 _test_image(
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 image,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 (guint8 *)edata,
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 elen,
38568
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
151 path,
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 "png",
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 "image/png"
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 );
38568
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
155
42184
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 38994
diff changeset
156 g_free(edata);
38568
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
157 g_free(path);
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 }
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 /******************************************************************************
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 * Main
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 *****************************************************************************/
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
163 int
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
164 main(int argc, char **argv) {
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 g_test_init(&argc, &argv, NULL);
38573
e890b91f60fe Use g_test_set_nonfatal_assertions when available
Gary Kramlich <grim@reaperworld.com>
parents: 38570
diff changeset
166 g_test_set_nonfatal_assertions();
e890b91f60fe Use g_test_set_nonfatal_assertions when available
Gary Kramlich <grim@reaperworld.com>
parents: 38570
diff changeset
167
38568
9463c7db20fa Set the path on the image for purple_image_new_from_file, update/add some tests
Gary Kramlich <grim@reaperworld.com>
parents: 38286
diff changeset
168 g_test_add_func("/image/new-from-bytes", test_image_new_from_bytes);
38286
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 g_test_add_func("/image/new-from-data", test_image_new_from_data);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 g_test_add_func("/image/new-from-file", test_image_new_from_file);
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 return g_test_run();
b9048b6c357e Add some unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 }

mercurial