1--TEST--
2Test 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
15echo "*** 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
25echo "\n--- Testing base64_encode() with binary string input ---\n";
26
27$counter = 1;
28foreach($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 --
50TEST PASSED
51-- Iteration 2 --
52TEST PASSED
53-- Iteration 3 --
54TEST PASSED
55-- Iteration 4 --
56TEST PASSED
57-- Iteration 5 --
58TEST PASSED
59===Done===
60