nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #include <glib.h> |
2 | #include <string.h> |
||
3 | |||
4 | static void |
||
5 | test_autofree (void) |
||
6 | { |
||
7 | g_autofree gchar *p = NULL; |
||
8 | g_autofree gchar *p2 = NULL; |
||
9 | g_autofree gchar *alwaysnull = NULL; |
||
10 | |||
11 | p = g_malloc (10); |
||
12 | p2 = g_malloc (42); |
||
13 | |||
14 | if (TRUE) |
||
15 | { |
||
16 | g_autofree guint8 *buf = g_malloc (128); |
||
17 | g_autofree gchar *alwaysnull_again = NULL; |
||
18 | |||
19 | buf[0] = 1; |
||
20 | } |
||
21 | |||
22 | if (TRUE) |
||
23 | { |
||
24 | g_autofree guint8 *buf2 = g_malloc (256); |
||
25 | |||
26 | buf2[255] = 42; |
||
27 | } |
||
28 | } |
||
29 | |||
30 | static void |
||
31 | test_g_async_queue (void) |
||
32 | { |
||
33 | g_autoptr(GAsyncQueue) val = g_async_queue_new (); |
||
34 | g_assert (val != NULL); |
||
35 | } |
||
36 | |||
37 | static void |
||
38 | test_g_bookmark_file (void) |
||
39 | { |
||
40 | g_autoptr(GBookmarkFile) val = g_bookmark_file_new (); |
||
41 | g_assert (val != NULL); |
||
42 | } |
||
43 | |||
44 | static void |
||
45 | test_g_bytes (void) |
||
46 | { |
||
47 | g_autoptr(GBytes) val = g_bytes_new ("foo", 3); |
||
48 | g_assert (val != NULL); |
||
49 | } |
||
50 | |||
51 | static void |
||
52 | test_g_checksum (void) |
||
53 | { |
||
54 | g_autoptr(GChecksum) val = g_checksum_new (G_CHECKSUM_SHA256); |
||
55 | g_assert (val != NULL); |
||
56 | } |
||
57 | |||
58 | static void |
||
59 | test_g_date_time (void) |
||
60 | { |
||
61 | g_autoptr(GDateTime) val = g_date_time_new_now_utc (); |
||
62 | g_assert (val != NULL); |
||
63 | } |
||
64 | |||
65 | static void |
||
66 | test_g_dir (void) |
||
67 | { |
||
68 | g_autoptr(GDir) val = g_dir_open (".", 0, NULL); |
||
69 | g_assert (val != NULL); |
||
70 | } |
||
71 | |||
72 | static void |
||
73 | test_g_error (void) |
||
74 | { |
||
75 | g_autoptr(GError) val = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED, "oops"); |
||
76 | g_assert (val != NULL); |
||
77 | } |
||
78 | |||
79 | static void |
||
80 | test_g_hash_table (void) |
||
81 | { |
||
82 | g_autoptr(GHashTable) val = g_hash_table_new (NULL, NULL); |
||
83 | g_assert (val != NULL); |
||
84 | } |
||
85 | |||
86 | static void |
||
87 | test_g_hmac (void) |
||
88 | { |
||
89 | g_autoptr(GHmac) val = g_hmac_new (G_CHECKSUM_SHA256, (guint8*)"hello", 5); |
||
90 | g_assert (val != NULL); |
||
91 | } |
||
92 | |||
93 | static void |
||
94 | test_g_io_channel (void) |
||
95 | { |
||
96 | g_autoptr(GIOChannel) val = g_io_channel_new_file ("/dev/null", "r", NULL); |
||
97 | g_assert (val != NULL); |
||
98 | } |
||
99 | |||
100 | static void |
||
101 | test_g_key_file (void) |
||
102 | { |
||
103 | g_autoptr(GKeyFile) val = g_key_file_new (); |
||
104 | g_assert (val != NULL); |
||
105 | } |
||
106 | |||
107 | static void |
||
108 | test_g_list (void) |
||
109 | { |
||
110 | g_autoptr(GList) val = NULL; |
||
111 | g_autoptr(GList) val2 = g_list_prepend (NULL, "foo"); |
||
112 | g_assert (val == NULL); |
||
113 | g_assert (val2 != NULL); |
||
114 | } |
||
115 | |||
116 | static void |
||
117 | test_g_array (void) |
||
118 | { |
||
119 | g_autoptr(GArray) val = g_array_new (0, 0, sizeof (gpointer)); |
||
120 | g_assert (val != NULL); |
||
121 | } |
||
122 | |||
123 | static void |
||
124 | test_g_ptr_array (void) |
||
125 | { |
||
126 | g_autoptr(GPtrArray) val = g_ptr_array_new (); |
||
127 | g_assert (val != NULL); |
||
128 | } |
||
129 | |||
130 | static void |
||
131 | test_g_byte_array (void) |
||
132 | { |
||
133 | g_autoptr(GByteArray) val = g_byte_array_new (); |
||
134 | g_assert (val != NULL); |
||
135 | } |
||
136 | |||
137 | static void |
||
138 | test_g_main_context (void) |
||
139 | { |
||
140 | g_autoptr(GMainContext) val = g_main_context_new (); |
||
141 | g_assert (val != NULL); |
||
142 | } |
||
143 | |||
144 | static void |
||
145 | test_g_main_loop (void) |
||
146 | { |
||
147 | g_autoptr(GMainLoop) val = g_main_loop_new (NULL, TRUE); |
||
148 | g_assert (val != NULL); |
||
149 | } |
||
150 | |||
151 | static void |
||
152 | test_g_source (void) |
||
153 | { |
||
154 | g_autoptr(GSource) val = g_timeout_source_new_seconds (2); |
||
155 | g_assert (val != NULL); |
||
156 | } |
||
157 | |||
158 | static void |
||
159 | test_g_mapped_file (void) |
||
160 | { |
||
161 | g_autoptr(GMappedFile) val = g_mapped_file_new (g_test_get_filename (G_TEST_DIST, "keyfiletest.ini", NULL), FALSE, NULL); |
||
162 | g_assert (val != NULL); |
||
163 | } |
||
164 | |||
165 | static void |
||
166 | parser_start (GMarkupParseContext *context, |
||
167 | const gchar *element_name, |
||
168 | const gchar **attribute_names, |
||
169 | const gchar **attribute_values, |
||
170 | gpointer user_data, |
||
171 | GError **error) |
||
172 | { |
||
173 | } |
||
174 | |||
175 | static void |
||
176 | parser_end (GMarkupParseContext *context, |
||
177 | const gchar *element_name, |
||
178 | gpointer user_data, |
||
179 | GError **error) |
||
180 | { |
||
181 | } |
||
182 | |||
183 | static GMarkupParser parser = { |
||
184 | .start_element = parser_start, |
||
185 | .end_element = parser_end |
||
186 | }; |
||
187 | |||
188 | static void |
||
189 | test_g_markup_parse_context (void) |
||
190 | { |
||
191 | g_autoptr(GMarkupParseContext) val = g_markup_parse_context_new (&parser, 0, NULL, NULL); |
||
192 | g_assert (val != NULL); |
||
193 | } |
||
194 | |||
195 | static void |
||
196 | test_g_node (void) |
||
197 | { |
||
198 | g_autoptr(GNode) val = g_node_new ("hello"); |
||
199 | g_assert (val != NULL); |
||
200 | } |
||
201 | |||
202 | static void |
||
203 | test_g_option_context (void) |
||
204 | { |
||
205 | g_autoptr(GOptionContext) val = g_option_context_new ("hello"); |
||
206 | g_assert (val != NULL); |
||
207 | } |
||
208 | |||
209 | static void |
||
210 | test_g_option_group (void) |
||
211 | { |
||
212 | g_autoptr(GOptionGroup) val = g_option_group_new ("hello", "world", "helpme", NULL, NULL); |
||
213 | g_assert (val != NULL); |
||
214 | } |
||
215 | |||
216 | static void |
||
217 | test_g_pattern_spec (void) |
||
218 | { |
||
219 | g_autoptr(GPatternSpec) val = g_pattern_spec_new ("plaid"); |
||
220 | g_assert (val != NULL); |
||
221 | } |
||
222 | |||
223 | static void |
||
224 | test_g_queue (void) |
||
225 | { |
||
226 | g_autoptr(GQueue) val = g_queue_new (); |
||
227 | g_auto(GQueue) stackval = G_QUEUE_INIT; |
||
228 | g_assert (val != NULL); |
||
229 | } |
||
230 | |||
231 | static void |
||
232 | test_g_rand (void) |
||
233 | { |
||
234 | g_autoptr(GRand) val = g_rand_new (); |
||
235 | g_assert (val != NULL); |
||
236 | } |
||
237 | |||
238 | static void |
||
239 | test_g_regex (void) |
||
240 | { |
||
241 | g_autoptr(GRegex) val = g_regex_new (".*", 0, 0, NULL); |
||
242 | g_assert (val != NULL); |
||
243 | } |
||
244 | |||
245 | static void |
||
246 | test_g_match_info (void) |
||
247 | { |
||
248 | g_autoptr(GRegex) regex = g_regex_new (".*", 0, 0, NULL); |
||
249 | g_autoptr(GMatchInfo) match = NULL; |
||
250 | |||
251 | if (!g_regex_match (regex, "hello", 0, &match)) |
||
252 | g_assert_not_reached (); |
||
253 | } |
||
254 | |||
255 | static void |
||
256 | test_g_scanner (void) |
||
257 | { |
||
258 | GScannerConfig config = { 0, }; |
||
259 | g_autoptr(GScanner) val = g_scanner_new (&config); |
||
260 | g_assert (val != NULL); |
||
261 | } |
||
262 | |||
263 | static void |
||
264 | test_g_sequence (void) |
||
265 | { |
||
266 | g_autoptr(GSequence) val = g_sequence_new (NULL); |
||
267 | g_assert (val != NULL); |
||
268 | } |
||
269 | |||
270 | static void |
||
271 | test_g_slist (void) |
||
272 | { |
||
273 | g_autoptr(GSList) val = NULL; |
||
274 | g_autoptr(GSList) nonempty_val = g_slist_prepend (NULL, "hello"); |
||
275 | g_assert (val == NULL); |
||
276 | g_assert (nonempty_val != NULL); |
||
277 | } |
||
278 | |||
279 | static void |
||
280 | test_g_string (void) |
||
281 | { |
||
282 | g_autoptr(GString) val = g_string_new (""); |
||
283 | g_assert (val != NULL); |
||
284 | } |
||
285 | |||
286 | static void |
||
287 | test_g_string_chunk (void) |
||
288 | { |
||
289 | g_autoptr(GStringChunk) val = g_string_chunk_new (42); |
||
290 | g_assert (val != NULL); |
||
291 | } |
||
292 | |||
293 | static gpointer |
||
294 | mythread (gpointer data) |
||
295 | { |
||
296 | g_usleep (G_USEC_PER_SEC); |
||
297 | return NULL; |
||
298 | } |
||
299 | |||
300 | static void |
||
301 | test_g_thread (void) |
||
302 | { |
||
303 | g_autoptr(GThread) val = g_thread_new ("bob", mythread, NULL); |
||
304 | g_assert (val != NULL); |
||
305 | } |
||
306 | |||
307 | static void |
||
308 | test_g_mutex (void) |
||
309 | { |
||
310 | g_auto(GMutex) val; |
||
311 | |||
312 | g_mutex_init (&val); |
||
313 | } |
||
314 | |||
315 | static void |
||
316 | test_g_mutex_locker (void) |
||
317 | { |
||
318 | GMutex mutex; |
||
319 | |||
320 | g_mutex_init (&mutex); |
||
321 | |||
322 | if (TRUE) |
||
323 | { |
||
324 | g_autoptr(GMutexLocker) val = g_mutex_locker_new (&mutex); |
||
325 | |||
326 | g_assert (val != NULL); |
||
327 | } |
||
328 | } |
||
329 | |||
330 | static void |
||
331 | test_g_cond (void) |
||
332 | { |
||
333 | g_auto(GCond) val; |
||
334 | g_cond_init (&val); |
||
335 | } |
||
336 | |||
337 | static void |
||
338 | test_g_timer (void) |
||
339 | { |
||
340 | g_autoptr(GTimer) val = g_timer_new (); |
||
341 | g_assert (val != NULL); |
||
342 | } |
||
343 | |||
344 | static void |
||
345 | test_g_time_zone (void) |
||
346 | { |
||
347 | g_autoptr(GTimeZone) val = g_time_zone_new ("UTC"); |
||
348 | g_assert (val != NULL); |
||
349 | } |
||
350 | |||
351 | static void |
||
352 | test_g_tree (void) |
||
353 | { |
||
354 | g_autoptr(GTree) val = g_tree_new ((GCompareFunc)strcmp); |
||
355 | g_assert (val != NULL); |
||
356 | } |
||
357 | |||
358 | static void |
||
359 | test_g_variant (void) |
||
360 | { |
||
361 | g_autoptr(GVariant) val = g_variant_new_string ("hello"); |
||
362 | g_assert (val != NULL); |
||
363 | } |
||
364 | |||
365 | static void |
||
366 | test_g_variant_builder (void) |
||
367 | { |
||
368 | g_autoptr(GVariantBuilder) val = g_variant_builder_new (G_VARIANT_TYPE ("as")); |
||
369 | g_auto(GVariantBuilder) stackval; |
||
370 | |||
371 | g_assert (val != NULL); |
||
372 | g_variant_builder_init (&stackval, G_VARIANT_TYPE ("as")); |
||
373 | } |
||
374 | |||
375 | static void |
||
376 | test_g_variant_iter (void) |
||
377 | { |
||
378 | g_autoptr(GVariant) var = g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32, "", 0, sizeof(guint32)); |
||
379 | g_autoptr(GVariantIter) val = g_variant_iter_new (var); |
||
380 | g_assert (val != NULL); |
||
381 | } |
||
382 | |||
383 | static void |
||
384 | test_g_variant_dict (void) |
||
385 | { |
||
386 | g_autoptr(GVariant) data = g_variant_new_from_data (G_VARIANT_TYPE ("a{sv}"), "", 0, FALSE, NULL, NULL); |
||
387 | g_auto(GVariantDict) stackval; |
||
388 | g_autoptr(GVariantDict) val = g_variant_dict_new (data); |
||
389 | |||
390 | g_variant_dict_init (&stackval, data); |
||
391 | g_assert (val != NULL); |
||
392 | } |
||
393 | |||
394 | static void |
||
395 | test_g_variant_type (void) |
||
396 | { |
||
397 | g_autoptr(GVariantType) val = g_variant_type_new ("s"); |
||
398 | g_assert (val != NULL); |
||
399 | } |
||
400 | |||
401 | static void |
||
402 | test_strv (void) |
||
403 | { |
||
404 | g_auto(GStrv) val = g_strsplit("a:b:c", ":", -1); |
||
405 | g_assert (val != NULL); |
||
406 | } |
||
407 | |||
408 | int |
||
409 | main (int argc, gchar *argv[]) |
||
410 | { |
||
411 | g_test_init (&argc, &argv, NULL); |
||
412 | |||
413 | g_test_add_func ("/autoptr/autofree", test_autofree); |
||
414 | g_test_add_func ("/autoptr/g_async_queue", test_g_async_queue); |
||
415 | g_test_add_func ("/autoptr/g_bookmark_file", test_g_bookmark_file); |
||
416 | g_test_add_func ("/autoptr/g_bytes", test_g_bytes); |
||
417 | g_test_add_func ("/autoptr/g_checksum", test_g_checksum); |
||
418 | g_test_add_func ("/autoptr/g_date_time", test_g_date_time); |
||
419 | g_test_add_func ("/autoptr/g_dir", test_g_dir); |
||
420 | g_test_add_func ("/autoptr/g_error", test_g_error); |
||
421 | g_test_add_func ("/autoptr/g_hash_table", test_g_hash_table); |
||
422 | g_test_add_func ("/autoptr/g_hmac", test_g_hmac); |
||
423 | g_test_add_func ("/autoptr/g_io_channel", test_g_io_channel); |
||
424 | g_test_add_func ("/autoptr/g_key_file", test_g_key_file); |
||
425 | g_test_add_func ("/autoptr/g_list", test_g_list); |
||
426 | g_test_add_func ("/autoptr/g_array", test_g_array); |
||
427 | g_test_add_func ("/autoptr/g_ptr_array", test_g_ptr_array); |
||
428 | g_test_add_func ("/autoptr/g_byte_array", test_g_byte_array); |
||
429 | g_test_add_func ("/autoptr/g_main_context", test_g_main_context); |
||
430 | g_test_add_func ("/autoptr/g_main_loop", test_g_main_loop); |
||
431 | g_test_add_func ("/autoptr/g_source", test_g_source); |
||
432 | g_test_add_func ("/autoptr/g_mapped_file", test_g_mapped_file); |
||
433 | g_test_add_func ("/autoptr/g_markup_parse_context", test_g_markup_parse_context); |
||
434 | g_test_add_func ("/autoptr/g_node", test_g_node); |
||
435 | g_test_add_func ("/autoptr/g_option_context", test_g_option_context); |
||
436 | g_test_add_func ("/autoptr/g_option_group", test_g_option_group); |
||
437 | g_test_add_func ("/autoptr/g_pattern_spec", test_g_pattern_spec); |
||
438 | g_test_add_func ("/autoptr/g_queue", test_g_queue); |
||
439 | g_test_add_func ("/autoptr/g_rand", test_g_rand); |
||
440 | g_test_add_func ("/autoptr/g_regex", test_g_regex); |
||
441 | g_test_add_func ("/autoptr/g_match_info", test_g_match_info); |
||
442 | g_test_add_func ("/autoptr/g_scanner", test_g_scanner); |
||
443 | g_test_add_func ("/autoptr/g_sequence", test_g_sequence); |
||
444 | g_test_add_func ("/autoptr/g_slist", test_g_slist); |
||
445 | g_test_add_func ("/autoptr/g_string", test_g_string); |
||
446 | g_test_add_func ("/autoptr/g_string_chunk", test_g_string_chunk); |
||
447 | g_test_add_func ("/autoptr/g_thread", test_g_thread); |
||
448 | g_test_add_func ("/autoptr/g_mutex", test_g_mutex); |
||
449 | g_test_add_func ("/autoptr/g_mutex_locker", test_g_mutex_locker); |
||
450 | g_test_add_func ("/autoptr/g_cond", test_g_cond); |
||
451 | g_test_add_func ("/autoptr/g_timer", test_g_timer); |
||
452 | g_test_add_func ("/autoptr/g_time_zone", test_g_time_zone); |
||
453 | g_test_add_func ("/autoptr/g_tree", test_g_tree); |
||
454 | g_test_add_func ("/autoptr/g_variant", test_g_variant); |
||
455 | g_test_add_func ("/autoptr/g_variant_builder", test_g_variant_builder); |
||
456 | g_test_add_func ("/autoptr/g_variant_iter", test_g_variant_iter); |
||
457 | g_test_add_func ("/autoptr/g_variant_dict", test_g_variant_dict); |
||
458 | g_test_add_func ("/autoptr/g_variant_type", test_g_variant_type); |
||
459 | g_test_add_func ("/autoptr/strv", test_strv); |
||
460 | |||
461 | return g_test_run (); |
||
462 | } |