diff options
author | Robin Fernandes <robinf@php.net> | 2008-04-11 08:57:17 +0000 |
---|---|---|
committer | Robin Fernandes <robinf@php.net> | 2008-04-11 08:57:17 +0000 |
commit | bcd9a07d6c6548764b6788fa15f6606d40085b51 (patch) | |
tree | bdb74db510a6f32eae1799cacde1ac4064512bed /ext/standard/tests/url/base64_decode_basic_002.phpt | |
parent | 7b22726093ba554e616b45127bb238d5bd005007 (diff) | |
download | php-git-bcd9a07d6c6548764b6788fa15f6606d40085b51.tar.gz |
Adding some tests for ereg and url functions.
Diffstat (limited to 'ext/standard/tests/url/base64_decode_basic_002.phpt')
-rw-r--r-- | ext/standard/tests/url/base64_decode_basic_002.phpt | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/ext/standard/tests/url/base64_decode_basic_002.phpt b/ext/standard/tests/url/base64_decode_basic_002.phpt new file mode 100644 index 0000000000..1289894f4a --- /dev/null +++ b/ext/standard/tests/url/base64_decode_basic_002.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test base64_decode() function : basic functionality - strict vs non-strict with non-base64 chars. +--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 "Decode 'hello world!':\n"; +$noWhiteSpace = "aGVsbG8gd29ybGQh"; +var_dump(base64_decode($noWhiteSpace)); +var_dump(base64_decode($noWhiteSpace, false)); +var_dump(base64_decode($noWhiteSpace, true)); + +echo "\nWhitespace does not affect base64_decode, even with \$strict===true:\n"; +$withWhiteSpace = "a GVs bG8gd2 + 9ybGQh"; +var_dump(base64_decode($withWhiteSpace)); +var_dump(base64_decode($withWhiteSpace, false)); +var_dump(base64_decode($withWhiteSpace, true)); + +echo "\nOther chars outside the base64 alphabet are ignored when \$strict===false, but cause failure with \$strict===true:\n"; +$badChars = $noWhiteSpace . '*'; +var_dump(base64_decode($badChars)); +var_dump(base64_decode($badChars, false)); +var_dump(base64_decode($badChars, true)); + +echo "Done"; +?> +--EXPECTF-- +Decode 'hello world!': +string(12) "hello world!" +string(12) "hello world!" +string(12) "hello world!" + +Whitespace does not affect base64_decode, even with $strict===true: +string(12) "hello world!" +string(12) "hello world!" +string(12) "hello world!" + +Other chars outside the base64 alphabet are ignored when $strict===false, but cause failure with $strict===true: +string(12) "hello world!" +string(12) "hello world!" +bool(false) +Done
\ No newline at end of file |