Roger Meier | c101092 | 2010-11-26 10:17:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 20 | #include <math.h> |
| 21 | #include <glib-object.h> |
| 22 | |
| 23 | #ifndef M_PI |
| 24 | #define M_PI 3.1415926535897932385 |
| 25 | #endif |
| 26 | |
| 27 | #include "gen-c_glib/t_test_debug_proto_test_types.h" |
| 28 | |
Roger Meier | c101092 | 2010-11-26 10:17:48 +0000 | [diff] [blame] | 29 | static void |
| 30 | test_debug_proto(void) |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 31 | { |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 32 | TTestOneOfEach *ooe = NULL; |
| 33 | TTestNesting *n = NULL; |
| 34 | TTestHolyMoley *hm = NULL; |
| 35 | |
| 36 | ooe = g_object_new (T_TEST_TYPE_ONE_OF_EACH, NULL); |
| 37 | ooe->im_true = TRUE; |
| 38 | ooe->im_false = FALSE; |
| 39 | ooe->a_bite = 0xd6; |
| 40 | ooe->integer16 = 27000; |
| 41 | ooe->integer32 = 1<<24; |
| 42 | ooe->integer64 = (guint64) 6000 * 1000 * 1000; |
| 43 | ooe->double_precision = M_PI; |
| 44 | ooe->some_characters = "Debug THIS!"; |
| 45 | ooe->zomg_unicode = "\xd7\n\a\t"; |
| 46 | |
| 47 | n = g_object_new (T_TEST_TYPE_NESTING, NULL); |
| 48 | n->my_ooe = ooe; |
| 49 | n->my_ooe->integer16 = 16; |
| 50 | n->my_ooe->integer32 = 32; |
| 51 | n->my_ooe->integer64 = 64; |
| 52 | n->my_ooe->double_precision = (sqrt(5.0) + 1) / 2; |
| 53 | n->my_ooe->some_characters = ":R (me going \"rrrr\")"; |
| 54 | n->my_ooe->zomg_unicode = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"; |
| 55 | n->my_bonk->type = 31337; |
| 56 | n->my_bonk->message = "I am a bonk... xor!"; |
| 57 | |
| 58 | hm = g_object_new (T_TEST_TYPE_HOLY_MOLEY, NULL); |
| 59 | g_ptr_array_add (hm->big, ooe); |
| 60 | g_ptr_array_add (hm->big, n->my_ooe); |
| 61 | ((TTestOneOfEach *) g_ptr_array_index (hm->big, 0))->a_bite = 0x22; |
| 62 | ((TTestOneOfEach *) g_ptr_array_index (hm->big, 1))->a_bite = 0x33; |
| 63 | |
| 64 | g_hash_table_insert (hm->contain, "random string", "random string"); |
| 65 | |
| 66 | TTestBonk *bonk = NULL; |
| 67 | bonk = g_object_new (T_TEST_TYPE_BONK, NULL); |
| 68 | GPtrArray *bonks = g_ptr_array_new (); |
| 69 | g_ptr_array_add (bonks, bonk); |
| 70 | g_hash_table_insert (hm->bonks, "nothing", bonks); |
| 71 | |
| 72 | g_ptr_array_free (bonks, TRUE); |
| 73 | g_object_unref (bonk); |
| 74 | g_object_unref (ooe); |
| 75 | g_object_unref (n); |
| 76 | g_object_unref (hm); |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | |
Roger Meier | c101092 | 2010-11-26 10:17:48 +0000 | [diff] [blame] | 81 | int |
| 82 | main(int argc, char *argv[]) |
| 83 | { |
| 84 | g_type_init(); |
| 85 | g_test_init (&argc, &argv, NULL); |
| 86 | |
| 87 | g_test_add_func ("/testdebugproto/DebugProto", test_debug_proto); |
| 88 | |
| 89 | return g_test_run (); |
| 90 | } |
| 91 | |
| 92 | |