From d52fbb83cc7b4b78f273cdc9c3a085654c638080 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 9 Dec 2015 14:23:12 -0800 Subject: [PATCH] Test metadata user data --- test/core/transport/metadata_test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c index 9c1eae95528..928fba7f452 100644 --- a/test/core/transport/metadata_test.c +++ b/test/core/transport/metadata_test.c @@ -241,6 +241,25 @@ static void test_base64_and_huffman_works(void) { grpc_shutdown(); } +static void test_user_data_works(void) { + int *ud1; + int *ud2; + grpc_mdelem *md; + LOG_TEST("test_user_data_works"); + + grpc_init(); + ud1 = gpr_malloc(sizeof(int)); + *ud1 = 1; + ud2 = gpr_malloc(sizeof(int)); + *ud2 = 2; + md = grpc_mdelem_from_strings("abc", "123"); + grpc_mdelem_set_user_data(md, gpr_free, ud1); + grpc_mdelem_set_user_data(md, gpr_free, ud2); + GPR_ASSERT(grpc_mdelem_get_user_data(md, gpr_free) == ud1); + GRPC_MDELEM_UNREF(md); + grpc_shutdown(); +} + int main(int argc, char **argv) { grpc_test_init(argc, argv); test_no_op(); @@ -252,5 +271,6 @@ int main(int argc, char **argv) { test_things_stick_around(); test_slices_work(); test_base64_and_huffman_works(); + test_user_data_works(); return 0; }