aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/support
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/support')
-rw-r--r--test/core/support/slice_test.c4
-rw-r--r--test/core/support/string_test.c35
2 files changed, 36 insertions, 3 deletions
diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c
index 2df38376a9..0da483a321 100644
--- a/test/core/support/slice_test.c
+++ b/test/core/support/slice_test.c
@@ -164,7 +164,7 @@ static void test_slice_split_head_works(size_t length) {
size_t i;
LOG_TEST_NAME("test_slice_split_head_works");
- gpr_log(GPR_INFO, "length=%d", length);
+ gpr_log(GPR_INFO, "length=%" PRIuPTR, length);
/* Create a slice in which each byte is equal to the distance from it to the
beginning of the slice. */
@@ -192,7 +192,7 @@ static void test_slice_split_tail_works(size_t length) {
size_t i;
LOG_TEST_NAME("test_slice_split_tail_works");
- gpr_log(GPR_INFO, "length=%d", length);
+ gpr_log(GPR_INFO, "length=%" PRIuPTR, length);
/* Create a slice in which each byte is equal to the distance from it to the
beginning of the slice. */
diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c
index d5f8107f21..553a824b3f 100644
--- a/test/core/support/string_test.c
+++ b/test/core/support/string_test.c
@@ -156,7 +156,7 @@ static void test_asprintf(void) {
LOG_TEST_NAME("test_asprintf");
/* Print an empty string. */
- GPR_ASSERT(gpr_asprintf(&buf, "") == 0);
+ GPR_ASSERT(gpr_asprintf(&buf, "%s", "") == 0);
GPR_ASSERT(buf[0] == '\0');
gpr_free(buf);
@@ -334,6 +334,38 @@ static void test_int64toa() {
GPR_ASSERT(0 == strcmp("-9223372036854775808", buf));
}
+static void test_leftpad() {
+ char *padded;
+
+ padded = gpr_leftpad("foo", ' ', 5);
+ GPR_ASSERT(0 == strcmp(" foo", padded));
+ gpr_free(padded);
+
+ padded = gpr_leftpad("foo", ' ', 4);
+ GPR_ASSERT(0 == strcmp(" foo", padded));
+ gpr_free(padded);
+
+ padded = gpr_leftpad("foo", ' ', 3);
+ GPR_ASSERT(0 == strcmp("foo", padded));
+ gpr_free(padded);
+
+ padded = gpr_leftpad("foo", ' ', 2);
+ GPR_ASSERT(0 == strcmp("foo", padded));
+ gpr_free(padded);
+
+ padded = gpr_leftpad("foo", ' ', 1);
+ GPR_ASSERT(0 == strcmp("foo", padded));
+ gpr_free(padded);
+
+ padded = gpr_leftpad("foo", ' ', 0);
+ GPR_ASSERT(0 == strcmp("foo", padded));
+ gpr_free(padded);
+
+ padded = gpr_leftpad("foo", '0', 5);
+ GPR_ASSERT(0 == strcmp("00foo", padded));
+ gpr_free(padded);
+}
+
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
test_strdup();
@@ -346,5 +378,6 @@ int main(int argc, char **argv) {
test_strsplit();
test_ltoa();
test_int64toa();
+ test_leftpad();
return 0;
}