Annotation of embedaddon/php/ext/standard/tests/url/base64_encode_basic_002.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test base64_encode() function : basic functionality - check algorithm round trips
3: --FILE--
4: <?php
5: /* Prototype : proto string base64_encode(string str)
6: * Description: Encodes string using MIME base64 algorithm
7: * Source code: ext/standard/base64.c
8: * Alias to functions:
9: */
10:
11: /*
12: * Test base64_encode with single byte values.
13: */
14:
15: echo "*** Testing base64_encode() : basic functionality ***\n";
16:
17: $values = array(
18: "Hello World",
19: "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!%^&*(){}[]",
20: "\n\t Line with control characters\r\n",
21: "\xC1\xC2\xC3\xC4\xC5\xC6",
22: "\75\76\77\78\79\80"
23: );
24:
25: echo "\n--- Testing base64_encode() with binary string input ---\n";
26:
27: $counter = 1;
28: foreach($values as $str) {
29: echo "-- Iteration $counter --\n";
30:
31: $enc = base64_encode($str);
32: $dec = base64_decode($enc);
33:
34: if ($dec != $str) {
35: echo "TEST FAILED\n";
36: } else {
37: echo "TEST PASSED\n";
38: }
39:
40: $counter ++;
41: }
42:
43: ?>
44: ===Done===
45: --EXPECTF--
46: *** Testing base64_encode() : basic functionality ***
47:
48: --- Testing base64_encode() with binary string input ---
49: -- Iteration 1 --
50: TEST PASSED
51: -- Iteration 2 --
52: TEST PASSED
53: -- Iteration 3 --
54: TEST PASSED
55: -- Iteration 4 --
56: TEST PASSED
57: -- Iteration 5 --
58: TEST PASSED
59: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>