Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame^] | 1 | #include <math.h> |
| 2 | #include <glib-object.h> |
| 3 | |
| 4 | #ifndef M_PI |
| 5 | #define M_PI 3.1415926535897932385 |
| 6 | #endif |
| 7 | |
| 8 | #include "gen-c_glib/t_test_debug_proto_test_types.h" |
| 9 | |
| 10 | |
| 11 | int |
| 12 | main(void) |
| 13 | { |
| 14 | g_type_init (); |
| 15 | |
| 16 | TTestOneOfEach *ooe = NULL; |
| 17 | TTestNesting *n = NULL; |
| 18 | TTestHolyMoley *hm = NULL; |
| 19 | |
| 20 | ooe = g_object_new (T_TEST_TYPE_ONE_OF_EACH, NULL); |
| 21 | ooe->im_true = TRUE; |
| 22 | ooe->im_false = FALSE; |
| 23 | ooe->a_bite = 0xd6; |
| 24 | ooe->integer16 = 27000; |
| 25 | ooe->integer32 = 1<<24; |
| 26 | ooe->integer64 = (guint64) 6000 * 1000 * 1000; |
| 27 | ooe->double_precision = M_PI; |
| 28 | ooe->some_characters = "Debug THIS!"; |
| 29 | ooe->zomg_unicode = "\xd7\n\a\t"; |
| 30 | |
| 31 | n = g_object_new (T_TEST_TYPE_NESTING, NULL); |
| 32 | n->my_ooe = ooe; |
| 33 | n->my_ooe->integer16 = 16; |
| 34 | n->my_ooe->integer32 = 32; |
| 35 | n->my_ooe->integer64 = 64; |
| 36 | n->my_ooe->double_precision = (sqrt(5.0) + 1) / 2; |
| 37 | n->my_ooe->some_characters = ":R (me going \"rrrr\")"; |
| 38 | n->my_ooe->zomg_unicode = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"; |
| 39 | n->my_bonk->type = 31337; |
| 40 | n->my_bonk->message = "I am a bonk... xor!"; |
| 41 | |
| 42 | hm = g_object_new (T_TEST_TYPE_HOLY_MOLEY, NULL); |
| 43 | g_ptr_array_add (hm->big, ooe); |
| 44 | g_ptr_array_add (hm->big, n->my_ooe); |
| 45 | ((TTestOneOfEach *) g_ptr_array_index (hm->big, 0))->a_bite = 0x22; |
| 46 | ((TTestOneOfEach *) g_ptr_array_index (hm->big, 1))->a_bite = 0x33; |
| 47 | |
| 48 | g_hash_table_insert (hm->contain, "random string", "random string"); |
| 49 | |
| 50 | TTestBonk *bonk = NULL; |
| 51 | bonk = g_object_new (T_TEST_TYPE_BONK, NULL); |
| 52 | GPtrArray *bonks = g_ptr_array_new (); |
| 53 | g_ptr_array_add (bonks, bonk); |
| 54 | g_hash_table_insert (hm->bonks, "nothing", bonks); |
| 55 | |
| 56 | g_ptr_array_free (bonks, TRUE); |
| 57 | g_object_unref (bonk); |
| 58 | g_object_unref (ooe); |
| 59 | g_object_unref (n); |
| 60 | g_object_unref (hm); |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |