summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2020-11-27 20:46:43 +0000
committerYann Ylavic <ylavic@apache.org>2020-11-27 20:46:43 +0000
commit1c4931097d53c5056e4010ec4e5d0f3bf34d06e5 (patch)
treeccc90715080cf78112cdbc193ff8b86eea9279b9 /test
parent31cf18582df6c467e12d59bf3850427a7f6a5a30 (diff)
downloadapr-1c4931097d53c5056e4010ec4e5d0f3bf34d06e5.tar.gz
Merge r1883870 from trunk:
apr_decode_base{64,32,16}: stop reading before (not including) NUL byte. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1883880 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/testencode.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/test/testencode.c b/test/testencode.c
index 3680fa380..ba23aaf28 100644
--- a/test/testencode.c
+++ b/test/testencode.c
@@ -134,37 +134,42 @@ static void test_decode_base64(abts_case * tc, void *data)
src = "";
target = "";
dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
- ABTS_STR_EQUAL(tc, dest, target);
+ ABTS_STR_EQUAL(tc, target, dest);
src = "Zg==";
target = "f";
dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
- ABTS_STR_EQUAL(tc, dest, target);
+ ABTS_STR_EQUAL(tc, target, dest);
+
+ src = "Zg=";
+ target = "f";
+ dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
+ ABTS_STR_EQUAL(tc, target, dest);
src = "Zg";
target = "f";
dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
- ABTS_STR_EQUAL(tc, dest, target);
+ ABTS_STR_EQUAL(tc, target, dest);
src = "Zm8=";
target = "fo";
dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
- ABTS_STR_EQUAL(tc, dest, target);
+ ABTS_STR_EQUAL(tc, target, dest);
src = "Zm8";
target = "fo";
dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
- ABTS_STR_EQUAL(tc, dest, target);
+ ABTS_STR_EQUAL(tc, target, dest);
src = "Zm9v";
target = "foo";
dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
- ABTS_STR_EQUAL(tc, dest, target);
+ ABTS_STR_EQUAL(tc, target, dest);
src = "Zm9v";
target = "foo";
dest = apr_pdecode_base64(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
- ABTS_STR_EQUAL(tc, dest, target);
+ ABTS_STR_EQUAL(tc, target, dest);
apr_pool_destroy(pool);
}
@@ -191,6 +196,11 @@ static void test_decode_base64_binary(abts_case * tc, void *data)
ABTS_ASSERT(tc, "apr_pdecode_base64_binary target!=dest", memcmp(ufoobar, udest, 1) == 0);
ABTS_INT_EQUAL(tc, len, 1);
+ src = "Zg=";
+ udest = apr_pdecode_base64_binary(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
+ ABTS_ASSERT(tc, "apr_pdecode_base64_binary target!=dest", memcmp(ufoobar, udest, 1) == 0);
+ ABTS_INT_EQUAL(tc, len, 1);
+
src = "Zg";
udest = apr_pdecode_base64_binary(pool, src, APR_ENCODE_STRING, APR_ENCODE_NONE, &len);
ABTS_ASSERT(tc, "apr_pdecode_base64_binary target!=dest", memcmp(ufoobar, udest, 1) == 0);