diff options
Diffstat (limited to 'test/core/security/b64_test.c')
-rw-r--r-- | test/core/security/b64_test.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/test/core/security/b64_test.c b/test/core/security/b64_test.c index b26bd026fd..af883f51e9 100644 --- a/test/core/security/b64_test.c +++ b/test/core/security/b64_test.c @@ -35,9 +35,9 @@ #include <string.h> +#include <grpc/slice.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/slice.h> #include "test/core/util/test_config.h" static int buffers_are_equal(const unsigned char *buf1, @@ -57,12 +57,12 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) { const char *hello = "hello"; char *hello_b64 = grpc_base64_encode(hello, strlen(hello), url_safe, multiline); - gpr_slice hello_slice = grpc_base64_decode(hello_b64, url_safe); - GPR_ASSERT(GPR_SLICE_LENGTH(hello_slice) == strlen(hello)); - GPR_ASSERT(strncmp((const char *)GPR_SLICE_START_PTR(hello_slice), hello, - GPR_SLICE_LENGTH(hello_slice)) == 0); + grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe); + GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello)); + GPR_ASSERT(strncmp((const char *)GRPC_SLICE_START_PTR(hello_slice), hello, + GRPC_SLICE_LENGTH(hello_slice)) == 0); - gpr_slice_unref(hello_slice); + grpc_slice_unref(hello_slice); gpr_free(hello_b64); } @@ -70,17 +70,17 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) { unsigned char orig[256]; size_t i; char *b64; - gpr_slice orig_decoded; + grpc_slice orig_decoded; for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; /* Try all the different paddings. */ for (i = 0; i < 3; i++) { b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline); orig_decoded = grpc_base64_decode(b64, url_safe); - GPR_ASSERT(GPR_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i)); - GPR_ASSERT(buffers_are_equal(orig, GPR_SLICE_START_PTR(orig_decoded), + GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i)); + GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded), sizeof(orig) - i)); - gpr_slice_unref(orig_decoded); + grpc_slice_unref(orig_decoded); gpr_free(b64); } } @@ -121,21 +121,21 @@ static void test_url_safe_unsafe_mismtach_failure(void) { unsigned char orig[256]; size_t i; char *b64; - gpr_slice orig_decoded; + grpc_slice orig_decoded; int url_safe = 1; for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0); orig_decoded = grpc_base64_decode(b64, !url_safe); - GPR_ASSERT(GPR_SLICE_IS_EMPTY(orig_decoded)); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded)); gpr_free(b64); - gpr_slice_unref(orig_decoded); + grpc_slice_unref(orig_decoded); b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0); orig_decoded = grpc_base64_decode(b64, url_safe); - GPR_ASSERT(GPR_SLICE_IS_EMPTY(orig_decoded)); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded)); gpr_free(b64); - gpr_slice_unref(orig_decoded); + grpc_slice_unref(orig_decoded); } static void test_rfc4648_test_vectors(void) { @@ -171,40 +171,40 @@ static void test_rfc4648_test_vectors(void) { } static void test_unpadded_decode(void) { - gpr_slice decoded; + grpc_slice decoded; decoded = grpc_base64_decode("Zm9vYmFy", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "foobar") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm9vYmE", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "fooba") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm9vYg", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "foob") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm9v", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "foo") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm8", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "fo") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zg", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "f") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("", 0); - GPR_ASSERT(GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded)); } int main(int argc, char **argv) { |