diff options
author | 2015-12-09 15:32:20 -0800 | |
---|---|---|
committer | 2015-12-09 15:32:20 -0800 | |
commit | e97326c5d436f59514191777cf16f62ca9b68cb9 (patch) | |
tree | 33f5d835fa904a6e6a29eb283711d1c0fde75772 | |
parent | 9bfc2ce06cd700fcbaa701914b4b294b7d601948 (diff) | |
parent | d52fbb83cc7b4b78f273cdc9c3a085654c638080 (diff) |
Merge pull request #4373 from ctiller/metatest
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; } |