com php-src: base64_decode: Add tests: ext/stan dard/tests/url/base64_decode_basic_003.phpt
| From: | Nikita Popov | Date: | Fri, 22 Jul 2016 16:03:56 +0000 |
| Subject: | com php-src: base64_decode: Add tests: ext/stan dard/tests/url/base64_decode_basic_003.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93325@lists.php.net to get a copy of this message | ||
Commit: cab5f6a8893ba03143436b4838aa1e144ea717fc
Author: Lauri Kenttä <lauri.kentta@gmail.com> Mon, 11 Jul 2016 12:57:09 +0300
Committer: Nikita Popov <nikic@php.net> Fri, 22 Jul 2016 18:03:56 +0200
Parents: 316d5a19a629488a64d623de14b323d1165755a2
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cab5f6a8893ba03143436b4838aa1e144ea717fc
Log:
base64_decode: Add tests
Changed paths:
A ext/standard/tests/url/base64_decode_basic_003.phpt
Diff:
diff --git a/ext/standard/tests/url/base64_decode_basic_003.phpt
b/ext/standard/tests/url/base64_decode_basic_003.phpt
new file mode 100644
index 0000000..981dade
--- /dev/null
+++ b/ext/standard/tests/url/base64_decode_basic_003.phpt
@@ -0,0 +1,118 @@
+--TEST--
+Test base64_decode() function : basic functionality - padding and whitespace
+--FILE--
+<?php
+/* Prototype : proto string base64_decode(string str[, bool strict])
+ * Description: Decodes string using MIME base64 algorithm
+ * Source code: ext/standard/base64.c
+ * Alias to functions:
+ */
+
+echo "Test base64_decode (output as JSON):\n";
+$data = [
+ "", "=", "==", "===", "====",
+ "V", "V=", "V==", "V===", "V====",
+ "VV", "VV=", "VV==", "VV===", "VV====",
+ "VVV", "VVV=", "VVV==", "VVV===", "VVV====",
+ "VVVV", "VVVV=", "VVVV==", "VVVV===",
"VVVV====",
+ "=V", "=VV", "=VVV",
+ "==V", "==VV", "==VVV",
+ "===V", "===VV", "===VVV",
+ "====V", "====VV", "====VVV",
+ "=VVV", "V=VV", "VV=V", "VVV=",
+ "=VVVV", "V=VVV", "VV=VV", "VVV=V", "VVVV=",
+ "=VVV=", "V=VV=", "VV=V=", "VVV==",
+ "\nVV", "V\nV", "VV\n",
+ "\nVV==", "V\nV==", "VV\n==", "VV=\n=",
"VV==\n",
+ "*VV", "V*V", "VV*",
+ "*VV==", "V*V==", "VV*==", "VV=*=", "VV==*",
+ "\0VV==", "V\0V==", "VV\0==", "VV=\0=",
"VV==\0",
+ "\0VVV==", "V\0VV==", "VV\0V==", "VVV\0==",
"VVV=\0=", "VVV==\0",
+];
+foreach ($data as $a) {
+ $b = base64_decode($a, false);
+ $c = base64_decode($a, true);
+ printf("base64 %-16s non-strict %-8s strict %s\n", json_encode($a), json_encode($b),
json_encode($c));
+}
+echo "Done\n";
+?>
+--EXPECTF--
+Test base64_decode (output as JSON):
+base64 "" non-strict "" strict ""
+base64 "=" non-strict "" strict false
+base64 "==" non-strict "" strict false
+base64 "===" non-strict "" strict false
+base64 "====" non-strict "" strict false
+base64 "V" non-strict "" strict false
+base64 "V=" non-strict "" strict false
+base64 "V==" non-strict "" strict false
+base64 "V===" non-strict "" strict false
+base64 "V====" non-strict "" strict false
+base64 "VV" non-strict "U" strict "U"
+base64 "VV=" non-strict "U" strict false
+base64 "VV==" non-strict "U" strict "U"
+base64 "VV===" non-strict "U" strict false
+base64 "VV====" non-strict "U" strict false
+base64 "VVV" non-strict "UU" strict "UU"
+base64 "VVV=" non-strict "UU" strict "UU"
+base64 "VVV==" non-strict "UU" strict false
+base64 "VVV===" non-strict "UU" strict false
+base64 "VVV====" non-strict "UU" strict false
+base64 "VVVV" non-strict "UUU" strict "UUU"
+base64 "VVVV=" non-strict "UUU" strict false
+base64 "VVVV==" non-strict "UUU" strict false
+base64 "VVVV===" non-strict "UUU" strict false
+base64 "VVVV====" non-strict "UUU" strict false
+base64 "=V" non-strict "" strict false
+base64 "=VV" non-strict "U" strict false
+base64 "=VVV" non-strict "UU" strict false
+base64 "==V" non-strict "" strict false
+base64 "==VV" non-strict "U" strict false
+base64 "==VVV" non-strict "UU" strict false
+base64 "===V" non-strict "" strict false
+base64 "===VV" non-strict "U" strict false
+base64 "===VVV" non-strict "UU" strict false
+base64 "====V" non-strict "" strict false
+base64 "====VV" non-strict "U" strict false
+base64 "====VVV" non-strict "UU" strict false
+base64 "=VVV" non-strict "UU" strict false
+base64 "V=VV" non-strict "UU" strict false
+base64 "VV=V" non-strict "UU" strict false
+base64 "VVV=" non-strict "UU" strict "UU"
+base64 "=VVVV" non-strict "UUU" strict false
+base64 "V=VVV" non-strict "UUU" strict false
+base64 "VV=VV" non-strict "UUU" strict false
+base64 "VVV=V" non-strict "UUU" strict false
+base64 "VVVV=" non-strict "UUU" strict false
+base64 "=VVV=" non-strict "UU" strict false
+base64 "V=VV=" non-strict "UU" strict false
+base64 "VV=V=" non-strict "UU" strict false
+base64 "VVV==" non-strict "UU" strict false
+base64 "\nVV" non-strict "U" strict "U"
+base64 "V\nV" non-strict "U" strict "U"
+base64 "VV\n" non-strict "U" strict "U"
+base64 "\nVV==" non-strict "U" strict "U"
+base64 "V\nV==" non-strict "U" strict "U"
+base64 "VV\n==" non-strict "U" strict "U"
+base64 "VV=\n=" non-strict "U" strict "U"
+base64 "VV==\n" non-strict "U" strict "U"
+base64 "*VV" non-strict "U" strict false
+base64 "V*V" non-strict "U" strict false
+base64 "VV*" non-strict "U" strict false
+base64 "*VV==" non-strict "U" strict false
+base64 "V*V==" non-strict "U" strict false
+base64 "VV*==" non-strict "U" strict false
+base64 "VV=*=" non-strict "U" strict false
+base64 "VV==*" non-strict "U" strict false
+base64 "\u0000VV==" non-strict "" strict false
+base64 "V\u0000V==" non-strict "" strict false
+base64 "VV\u0000==" non-strict "U" strict false
+base64 "VV=\u0000=" non-strict "U" strict false
+base64 "VV==\u0000" non-strict "U" strict false
+base64 "\u0000VVV==" non-strict "" strict false
+base64 "V\u0000VV==" non-strict "" strict false
+base64 "VV\u0000V==" non-strict "U" strict false
+base64 "VVV\u0000==" non-strict "UU" strict false
+base64 "VVV=\u0000=" non-strict "UU" strict false
+base64 "VVV==\u0000" non-strict "UU" strict false
+Done