diff options
author | Nobuaki Sukegawa <nsukeg@gmail.com> | 2015-09-29 02:16:53 +0900 |
---|---|---|
committer | Roger Meier <roger@apache.org> | 2015-09-28 20:38:37 +0200 |
commit | 01ede042aad2d44a0dbe11818dabef7897e04db4 (patch) | |
tree | c526ea0bf4a1317ff8cec2a9b0c6c01c341bb370 /test/c_glib | |
parent | f2c9f1b968f2b5716cf6b96b36e133cd7e07cde6 (diff) | |
download | thrift-01ede042aad2d44a0dbe11818dabef7897e04db4.tar.gz |
THRIFT-3360 Improve cross test servers and clients further
This closes #629
Diffstat (limited to 'test/c_glib')
-rw-r--r-- | test/c_glib/src/test_client.c | 26 | ||||
-rw-r--r-- | test/c_glib/src/thrift_test_handler.c | 55 |
2 files changed, 25 insertions, 56 deletions
diff --git a/test/c_glib/src/test_client.c b/test/c_glib/src/test_client.c index b1fe0657c..fd429c80a 100644 --- a/test/c_glib/src/test_client.c +++ b/test/c_glib/src/test_client.c @@ -204,7 +204,7 @@ main (int argc, char **argv) gint byte_thing, i32_thing, inner_byte_thing, inner_i32_thing; gint64 i64_thing, inner_i64_thing; - TTestXtruct *xtruct_out, *xtruct_in, *inner_xtruct_in; + TTestXtruct *xtruct_out, *xtruct_out2, *xtruct_in, *inner_xtruct_in; TTestXtruct2 *xtruct2_out, *xtruct2_in; GHashTable *map_out, *map_in, *inner_map_in; @@ -217,8 +217,9 @@ main (int argc, char **argv) GArray *list_out, *list_in; TTestNumberz numberz; + TTestNumberz numberz2; - TTestUserId user_id, *user_id_ptr; + TTestUserId user_id, *user_id_ptr, *user_id_ptr2; TTestInsanity *insanity_out, *insanity_in; GHashTable *user_map; @@ -1021,17 +1022,28 @@ main (int argc, char **argv) NULL); numberz = T_TEST_NUMBERZ_FIVE; + numberz2 = T_TEST_NUMBERZ_EIGHT; user_id_ptr = g_malloc (sizeof *user_id_ptr); - *user_id_ptr = 5000; + *user_id_ptr = 5; + user_id_ptr2 = g_malloc (sizeof *user_id_ptr); + *user_id_ptr2 = 8; g_hash_table_insert (user_map, (gpointer)numberz, user_id_ptr); + g_hash_table_insert (user_map, (gpointer)numberz2, user_id_ptr2); g_hash_table_unref (user_map); xtruct_out = g_object_new (T_TEST_TYPE_XTRUCT, - "string_thing", "Truck", - "byte_thing", 8, - "i32_thing", 8, - "i64_thing", 8LL, + "string_thing", "Hello2", + "byte_thing", 2, + "i32_thing", 2, + "i64_thing", 2LL, NULL); + xtruct_out2 = g_object_new (T_TEST_TYPE_XTRUCT, + "string_thing", "Goodbye4", + "byte_thing", 4, + "i32_thing", 4, + "i64_thing", 4LL, + NULL); + g_ptr_array_add (xtructs, xtruct_out2); g_ptr_array_add (xtructs, xtruct_out); g_ptr_array_unref (xtructs); diff --git a/test/c_glib/src/thrift_test_handler.c b/test/c_glib/src/thrift_test_handler.c index d82befbe6..a9983b5e6 100644 --- a/test/c_glib/src/thrift_test_handler.c +++ b/test/c_glib/src/thrift_test_handler.c @@ -472,8 +472,6 @@ thrift_test_handler_test_insanity (TTestThriftTestIf *iface, const TTestInsanity *argument, GError **error) { - TTestXtruct *hello; - TTestXtruct *goodbye; TTestXtruct *xtruct_in; gchar *string_thing = NULL; @@ -483,7 +481,6 @@ thrift_test_handler_test_insanity (TTestThriftTestIf *iface, GPtrArray *xtructs; - TTestInsanity *crazy; TTestInsanity *looney; GHashTable *user_map; @@ -502,50 +499,10 @@ thrift_test_handler_test_insanity (TTestThriftTestIf *iface, guint i; THRIFT_UNUSED_VAR (iface); - THRIFT_UNUSED_VAR (argument); THRIFT_UNUSED_VAR (error); printf ("testInsanity()\n"); - hello = g_object_new (T_TEST_TYPE_XTRUCT, - "string_thing", "Hello2", - "byte_thing", 2, - "i32_thing", 2, - "i64_thing", 2, - NULL); - - goodbye = g_object_new (T_TEST_TYPE_XTRUCT, - "string_thing", "Goodbye4", - "byte_thing", 4, - "i32_thing", 4, - "i64_thing", 4, - NULL); - - crazy = g_object_new (T_TEST_TYPE_INSANITY, NULL); - g_object_get (crazy, - "userMap", &user_map, - "xtructs", &xtructs, - NULL); - - user_id = g_malloc(sizeof *user_id); - *user_id = 8; - g_hash_table_insert (user_map, - GINT_TO_POINTER (T_TEST_NUMBERZ_EIGHT), - user_id); - - g_ptr_array_add (xtructs, goodbye); - - user_id = g_malloc(sizeof *user_id); - *user_id = 5; - g_hash_table_insert (user_map, - GINT_TO_POINTER (T_TEST_NUMBERZ_FIVE), - user_id); - - g_ptr_array_add (xtructs, hello); - - g_hash_table_unref (user_map); - g_ptr_array_unref (xtructs); - first_map = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, @@ -557,17 +514,17 @@ thrift_test_handler_test_insanity (TTestThriftTestIf *iface, g_hash_table_insert (first_map, GINT_TO_POINTER (T_TEST_NUMBERZ_TWO), - crazy); + argument); g_hash_table_insert (first_map, GINT_TO_POINTER (T_TEST_NUMBERZ_THREE), - crazy); + argument); - /* Increment crazy's ref count since first_map now holds two + /* Increment argument's ref count since first_map now holds two references to it and would otherwise attempt to deallocate it twice during destruction. We do this instead of creating a copy - of crazy in order to mimic the C++ implementation (and since, - frankly, the world needs less crazy, not more). */ - g_object_ref (crazy); + of argument in order to mimic the C++ implementation (and since, + frankly, the world needs less argument, not more). */ + g_object_ref (argument); looney = g_object_new (T_TEST_TYPE_INSANITY, NULL); g_hash_table_insert (second_map, |