diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-10-30 17:38:50 -0700 |
---|---|---|
committer | Yash Tibrewal <yashkt@google.com> | 2017-10-30 17:38:50 -0700 |
commit | c430c84f84bec9c97cb48b0ccfd212f52e10de93 (patch) | |
tree | c52c2e0e645230d5bf03887d8d7cd12aff34ad0d /test/core/statistics | |
parent | 268685bcbd1a3af4239f4cd0f623b5f6d033b524 (diff) |
more changes
Diffstat (limited to 'test/core/statistics')
-rw-r--r-- | test/core/statistics/hash_table_test.cc | 18 | ||||
-rw-r--r-- | test/core/statistics/window_stats_test.cc | 25 |
2 files changed, 22 insertions, 21 deletions
diff --git a/test/core/statistics/hash_table_test.cc b/test/core/statistics/hash_table_test.cc index d714e15091..72ea0d8066 100644 --- a/test/core/statistics/hash_table_test.cc +++ b/test/core/statistics/hash_table_test.cc @@ -89,7 +89,7 @@ static void test_table_with_int_key(void) { uint64_t *val = NULL; census_ht_key key; key.val = i; - val = census_ht_find(ht, key); + val = static_cast<uint64_t *>(census_ht_find(ht, key)); GPR_ASSERT(val == (void *)(intptr_t)i); } elements = census_ht_get_all_elements(ht, &num_elements); @@ -112,22 +112,22 @@ static void test_value_and_key_deleter(void) { char *val = NULL; char *val2 = NULL; key.ptr = gpr_malloc(100); - val = gpr_malloc(10); + val = static_cast<char *>(gpr_malloc(10)); strcpy(val, "value"); strcpy(key.ptr, "some string as a key"); GPR_ASSERT(ht != NULL); 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); + val = static_cast<char *>(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); + val2 = static_cast<char *>(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); + val2 = static_cast<char *>(census_ht_find(ht, key)); GPR_ASSERT(val2 != NULL); GPR_ASSERT(strcmp(val2, "v2") == 0); census_ht_destroy(ht); @@ -214,7 +214,7 @@ static void test_table_with_string_key(void) { census_ht_key key; int *val_ptr; key.ptr = (void *)(keys[i]); - val_ptr = census_ht_find(ht, key); + val_ptr = static_cast<int *>(census_ht_find(ht, key)); GPR_ASSERT(*val_ptr == vals[i]); } { @@ -225,7 +225,7 @@ static void test_table_with_string_key(void) { census_ht_insert(ht, key, (void *)(vals + 8)); /* expect value to be over written by new insertion */ GPR_ASSERT(census_ht_get_size(ht) == 9); - val_ptr = census_ht_find(ht, key); + val_ptr = static_cast<int *>(census_ht_find(ht, key)); GPR_ASSERT(*val_ptr == vals[8]); } for (i = 0; i < 9; i++) { @@ -234,11 +234,11 @@ static void test_table_with_string_key(void) { uint32_t expected_tbl_sz = 9 - i; GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz); key.ptr = (void *)(keys[i]); - val_ptr = census_ht_find(ht, key); + val_ptr = static_cast<int *>(census_ht_find(ht, key)); GPR_ASSERT(val_ptr != NULL); census_ht_erase(ht, key); GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz - 1); - val_ptr = census_ht_find(ht, key); + val_ptr = static_cast<int *>(census_ht_find(ht, key)); GPR_ASSERT(val_ptr == NULL); } census_ht_destroy(ht); diff --git a/test/core/statistics/window_stats_test.cc b/test/core/statistics/window_stats_test.cc index 254c14a6a8..91eafd5724 100644 --- a/test/core/statistics/window_stats_test.cc +++ b/test/core/statistics/window_stats_test.cc @@ -44,11 +44,11 @@ void add_proportion_test_stat(double p, void *base, const void *addme) { const struct census_window_stats_stat_info kMyStatInfo = { sizeof(test_stat), NULL, add_test_stat, add_proportion_test_stat}; -const gpr_timespec kMilliSecInterval = {0, 1000000}; -const gpr_timespec kSecInterval = {1, 0}; -const gpr_timespec kMinInterval = {60, 0}; -const gpr_timespec kHourInterval = {3600, 0}; -const gpr_timespec kPrimeInterval = {0, 101}; +const gpr_timespec kMilliSecInterval = {0, 1000000, GPR_CLOCK_MONOTONIC}; +const gpr_timespec kSecInterval = {1, 0, GPR_CLOCK_MONOTONIC}; +const gpr_timespec kMinInterval = {60, 0 GPR_CLOCK_MONOTONIC}; +const gpr_timespec kHourInterval = {3600, 0, GPR_CLOCK_MONOTONIC}; +const gpr_timespec kPrimeInterval = {0, 101, GPR_CLOCK_MONOTONIC}; static int compare_double(double a, double b, double epsilon) { if (a >= b) { @@ -60,7 +60,7 @@ static int compare_double(double a, double b, double epsilon) { void empty_test(void) { census_window_stats_sums result; - const gpr_timespec zero = {0, 0}; + const gpr_timespec zero = {0, 0, GPR_CLOCK_MONOTONIC}; test_stat sum; struct census_window_stats *stats = census_window_stats_create(1, &kMinInterval, 5, &kMyStatInfo); @@ -76,7 +76,7 @@ void empty_test(void) { void one_interval_test(void) { const test_stat value = {0.1, 4}; const double epsilon = 1e10 - 11; - gpr_timespec when = {0, 0}; + gpr_timespec when = {0, 0, GPR_CLOCK_MONOTONIC}; census_window_stats_sums result; test_stat sum; /* granularity == 5 so width of internal windows should be 12s */ @@ -186,7 +186,7 @@ void many_interval_test(void) { gpr_timespec intervals[4]; const test_stat value = {123.45, 8}; const double epsilon = 1e10 - 11; - gpr_timespec when = {3600, 0}; /* one hour */ + gpr_timespec when = {3600, 0, GPR_CLOCK_MONOTONIC}; /* one hour */ census_window_stats_sums result[4]; test_stat sums[4]; int i; @@ -245,11 +245,11 @@ void many_interval_test(void) { void rolling_time_test(void) { const test_stat value = {0.1, 4}; - gpr_timespec when = {0, 0}; + gpr_timespec when = {0, 0, GPR_CLOCK_MONOTONIC}; census_window_stats_sums result; test_stat sum; int i; - gpr_timespec increment = {0, 0}; + gpr_timespec increment = {0, 0, GPR_CLOCK_MONOTONIC}; struct census_window_stats *stats = census_window_stats_create(1, &kMinInterval, 7, &kMyStatInfo); GPR_ASSERT(stats != NULL); @@ -270,12 +270,13 @@ void rolling_time_test(void) { #include <stdio.h> void infinite_interval_test(void) { const test_stat value = {0.1, 4}; - gpr_timespec when = {0, 0}; + gpr_timespec when = {0, 0, GPR_CLOCK_MONOTONIC}; census_window_stats_sums result; test_stat sum; int i; const int count = 100000; - gpr_timespec increment = {0, 0}; + gpr_timespec increment = {0, 0, GPR_CLOCK_MONOTONIC}; + gpr_timespec temp = gpr_inf_future(GPR_CLOCK_REALTIME); struct census_window_stats *stats = census_window_stats_create( 1, &gpr_inf_future(GPR_CLOCK_REALTIME), 10, &kMyStatInfo); srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec); |