blob: 689e001ae06d6bf873ef843b1ec1e8512a84e592 [file] [log] [blame]
Roger Meierc1010922010-11-26 10:17:48 +00001/*
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 Meier213a6642010-10-27 12:30:11 +000020#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 Meierc1010922010-11-26 10:17:48 +000029static void
30test_debug_proto(void)
Roger Meier213a6642010-10-27 12:30:11 +000031{
Roger Meier213a6642010-10-27 12:30:11 +000032 TTestOneOfEach *ooe = NULL;
33 TTestNesting *n = NULL;
34 TTestHolyMoley *hm = NULL;
Roger Meierc75797d2012-04-28 11:33:58 +000035 gchar *random = g_strdup("random string");
36 gchar *nothing = g_strdup("nothing");
Roger Meier213a6642010-10-27 12:30:11 +000037
38 ooe = g_object_new (T_TEST_TYPE_ONE_OF_EACH, NULL);
39 ooe->im_true = TRUE;
40 ooe->im_false = FALSE;
41 ooe->a_bite = 0xd6;
42 ooe->integer16 = 27000;
43 ooe->integer32 = 1<<24;
44 ooe->integer64 = (guint64) 6000 * 1000 * 1000;
45 ooe->double_precision = M_PI;
Roger Meierc75797d2012-04-28 11:33:58 +000046 ooe->some_characters = g_strdup("Debug THIS!");
47 ooe->zomg_unicode = g_strdup("\xd7\n\a\t");
Roger Meier213a6642010-10-27 12:30:11 +000048
49 n = g_object_new (T_TEST_TYPE_NESTING, NULL);
Roger Meierc75797d2012-04-28 11:33:58 +000050 if (n->my_ooe != NULL)
51 g_object_unref(n->my_ooe);
52
Roger Meier213a6642010-10-27 12:30:11 +000053 n->my_ooe = ooe;
54 n->my_ooe->integer16 = 16;
55 n->my_ooe->integer32 = 32;
56 n->my_ooe->integer64 = 64;
57 n->my_ooe->double_precision = (sqrt(5.0) + 1) / 2;
Roger Meierc75797d2012-04-28 11:33:58 +000058 n->my_ooe->some_characters = g_strdup(":R (me going \"rrrr\")");
59 n->my_ooe->zomg_unicode = g_strdup("\xd3\x80\xe2\x85\xae\xce\x9d\x20");
Roger Meier213a6642010-10-27 12:30:11 +000060 n->my_bonk->type = 31337;
Roger Meierc75797d2012-04-28 11:33:58 +000061 n->my_bonk->message = g_strdup("I am a bonk... xor!");
Roger Meier213a6642010-10-27 12:30:11 +000062
63 hm = g_object_new (T_TEST_TYPE_HOLY_MOLEY, NULL);
64 g_ptr_array_add (hm->big, ooe);
Roger Meierc75797d2012-04-28 11:33:58 +000065 g_ptr_array_add (hm->big, g_object_ref(n->my_ooe));
Roger Meier213a6642010-10-27 12:30:11 +000066 ((TTestOneOfEach *) g_ptr_array_index (hm->big, 0))->a_bite = 0x22;
67 ((TTestOneOfEach *) g_ptr_array_index (hm->big, 1))->a_bite = 0x33;
68
Roger Meierc75797d2012-04-28 11:33:58 +000069 g_hash_table_insert (hm->contain, random, random);
Roger Meier213a6642010-10-27 12:30:11 +000070
71 TTestBonk *bonk = NULL;
72 bonk = g_object_new (T_TEST_TYPE_BONK, NULL);
Roger Meierc75797d2012-04-28 11:33:58 +000073 GPtrArray *bonks = g_ptr_array_new_with_free_func (g_object_unref);
Roger Meier213a6642010-10-27 12:30:11 +000074 g_ptr_array_add (bonks, bonk);
Roger Meierc75797d2012-04-28 11:33:58 +000075 g_hash_table_insert (hm->bonks, nothing, bonks);
Roger Meier213a6642010-10-27 12:30:11 +000076
Roger Meier213a6642010-10-27 12:30:11 +000077 g_object_unref (hm);
78
79 return 0;
80}
81
Roger Meierc1010922010-11-26 10:17:48 +000082int
83main(int argc, char *argv[])
84{
85 g_type_init();
86 g_test_init (&argc, &argv, NULL);
87
88 g_test_add_func ("/testdebugproto/DebugProto", test_debug_proto);
89
90 return g_test_run ();
91}
92
93