aboutsummaryrefslogtreecommitdiffstats
path: root/test.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-03-19 22:33:41 +0100
committerMattias Andrée <maandree@kth.se>2022-03-19 22:33:46 +0100
commitb5508dd1088acfc31a8a92fd9798fced0bcb41b3 (patch)
tree54bea20b98ed9848727230ff994e708e35e7a87d /test.c
parenttest: check libar2_decode_base64 with buffer overlap (diff)
downloadlibar2-b5508dd1088acfc31a8a92fd9798fced0bcb41b3.tar.gz
libar2-b5508dd1088acfc31a8a92fd9798fced0bcb41b3.tar.bz2
libar2-b5508dd1088acfc31a8a92fd9798fced0bcb41b3.tar.xz
libar2_encode_base64: fix support for overlap1.2.2
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--test.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/test.c b/test.c
index 115640e..cd68011 100644
--- a/test.c
+++ b/test.c
@@ -555,33 +555,49 @@ check_libar2_encode_base64(void)
assert_streq(buf, "");
assert(errno == 0);
- assert(libar2_encode_base64(buf, MEM("\x00")) == 3);
+#define ENCODE_BASE64(S) libar2_encode_base64(buf, MEM(S))
+
+ assert(ENCODE_BASE64("") == 1);
+ assert_streq(buf, "");
+ assert(errno == 0);
+
+ assert(ENCODE_BASE64("\x00") == 3);
assert_streq(buf, "AA");
assert(errno == 0);
- assert(libar2_encode_base64(buf, MEM("\x00\x00")) == 4);
+ assert(ENCODE_BASE64("\x00\x00") == 4);
assert_streq(buf, "AAA");
assert(errno == 0);
- assert(libar2_encode_base64(buf, MEM("\x00\x00\x00")) == 5);
+ assert(ENCODE_BASE64("\x00\x00\x00") == 5);
assert_streq(buf, "AAAA");
assert(errno == 0);
- assert(libar2_encode_base64(buf, MEM("12345678")) == 12);
+ assert(ENCODE_BASE64("12345678") == 12);
assert_streq(buf, "MTIzNDU2Nzg");
assert(errno == 0);
- assert(libar2_encode_base64(buf, MEM("testtest")) == 12);
+ assert(ENCODE_BASE64("testtest") == 12);
assert_streq(buf, "dGVzdHRlc3Q");
assert(errno == 0);
- assert(libar2_encode_base64(buf, MEM("zy[]y21 !")) == 13);
+ assert(ENCODE_BASE64("zy[]y21 !") == 13);
assert_streq(buf, "enlbXXkyMSAh");
assert(errno == 0);
+ assert(ENCODE_BASE64("{~|~}~~~\x7f\x7f") == 15);
+ assert_streq(buf, "e358fn1+fn5/fw");
+ assert(errno == 0);
+
+#undef ENCODE_BASE64
+
assert(libar2_encode_base64(buf, MEM("{~|~}~~~\x7f\x7f")) == 15);
assert_streq(buf, "e358fn1+fn5/fw");
assert(errno == 0);
+
+ assert(libar2_encode_base64_overlap_support(buf, MEM("{~|~}~~~\x7f\x7f")) == 15);
+ assert_streq(buf, "e358fn1+fn5/fw");
+ assert(errno == 0);
}