aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/statistics
diff options
context:
space:
mode:
authorGravatar hongyu <hongyu@google.com>2015-01-12 13:49:25 -0800
committerGravatar Nicolas Noble <nnoble@google.com>2015-01-12 14:11:52 -0800
commit99e317a8f8c9f71ede5fc2587589aa60989d3dac (patch)
tree9ae56a6eaabc96ac197b71da24dc71560b39f99b /test/core/statistics
parentd74729d8c78ab50d0219f03e831f1aabcbad0b15 (diff)
grpc census hash_table test coverage improvements.
Change on 2015/01/12 by hongyu <hongyu@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=83786701
Diffstat (limited to 'test/core/statistics')
-rw-r--r--test/core/statistics/hash_table_test.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/core/statistics/hash_table_test.c b/test/core/statistics/hash_table_test.c
index fb75de520e..8c76824193 100644
--- a/test/core/statistics/hash_table_test.c
+++ b/test/core/statistics/hash_table_test.c
@@ -123,7 +123,8 @@ static void test_value_and_key_deleter() {
&free_data, &free_data};
census_ht* ht = census_ht_create(&opt);
census_ht_key key;
- char* val;
+ char* val = NULL;
+ char* val2 = NULL;
key.ptr = gpr_malloc(100);
val = gpr_malloc(10);
strcpy(val, "value");
@@ -132,6 +133,17 @@ static void test_value_and_key_deleter() {
GPR_ASSERT(census_ht_get_size(ht) == 0);
census_ht_insert(ht, key, val);
GPR_ASSERT(census_ht_get_size(ht) == 1);
+ val = census_ht_find(ht, key);
+ GPR_ASSERT(val != NULL);
+ GPR_ASSERT(strcmp(val, "value") == 0);
+ /* Insert same key different value, old value is overwritten. */
+ val2 = gpr_malloc(10);
+ strcpy(val2, "v2");
+ census_ht_insert(ht, key, val2);
+ GPR_ASSERT(census_ht_get_size(ht) == 1);
+ val2 = census_ht_find(ht, key);
+ GPR_ASSERT(val2 != NULL);
+ GPR_ASSERT(strcmp(val2, "v2") == 0);
census_ht_destroy(ht);
}