diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-12-09 14:23:12 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-12-09 14:23:12 -0800 |
commit | d52fbb83cc7b4b78f273cdc9c3a085654c638080 (patch) | |
tree | 920ba66fac37884b5b25e149f8adac5798f14f27 | |
parent | 3ca448925ba3df03ef872ac127b5e70ccd35c1af (diff) |
Test metadata user data
-rw-r--r-- | test/core/transport/metadata_test.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c index 9c1eae9552..928fba7f45 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; } |