summaryrefslogtreecommitdiff
path: root/ext/standard/tests/url/base64_encode_basic_002.phpt
blob: cff8f41425036a99bc13e0d53a549032e356b7a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--TEST--
Test base64_encode() function : basic functionality - check algorithm round trips 
--FILE--
<?php
/* Prototype  : proto string base64_encode(string str)
 * Description: Encodes string using MIME base64 algorithm 
 * Source code: ext/standard/base64.c
 * Alias to functions: 
 */

/*
 * Test base64_encode with single byte values.
 */

echo "*** Testing base64_encode() : basic functionality ***\n";

$values = array(
	"Hello World",
	"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!%^&*(){}[]",
	"\n\t Line with control characters\r\n",
	"\xC1\xC2\xC3\xC4\xC5\xC6",
	"\75\76\77\78\79\80"
);

echo "\n--- Testing base64_encode() with binary string input ---\n";

$counter = 1;
foreach($values as $str) {
  	echo "-- Iteration $counter --\n";
  	
  	$enc = base64_encode($str);
	$dec = base64_decode($enc);

	if ($dec != $str) {
		echo "TEST FAILED\n";
	} else {
		echo "TEST PASSED\n";
	}	

  	$counter ++;
}

?>
===Done===
--EXPECTF--
*** Testing base64_encode() : basic functionality ***

--- Testing base64_encode() with binary string input ---
-- Iteration 1 --
TEST PASSED
-- Iteration 2 --
TEST PASSED
-- Iteration 3 --
TEST PASSED
-- Iteration 4 --
TEST PASSED
-- Iteration 5 --
TEST PASSED
===Done===