diff options
author | Sander Roobol <sander@php.net> | 2002-10-06 19:12:22 +0000 |
---|---|---|
committer | Sander Roobol <sander@php.net> | 2002-10-06 19:12:22 +0000 |
commit | 9edfd75a5c76e18ed6d7adfbc54a44e5aaea01b7 (patch) | |
tree | 3ea10a5c6a821f66fb1d9fc6a3a61d3924f3f506 /ext | |
parent | bd48e0cfe91d059cc85cf1f2e6307f2a61b868b1 (diff) | |
download | php-git-9edfd75a5c76e18ed6d7adfbc54a44e5aaea01b7.tar.gz |
Some string tests
Diffstat (limited to 'ext')
-rw-r--r-- | ext/standard/tests/strings/add-and-stripcslashes.phpt | 20 | ||||
-rw-r--r-- | ext/standard/tests/strings/bin2hex.phpt | 16 | ||||
-rw-r--r-- | ext/standard/tests/strings/chr_ord.phpt | 12 | ||||
-rw-r--r-- | ext/standard/tests/strings/chunk_split.phpt | 19 | ||||
-rw-r--r-- | ext/standard/tests/strings/count_chars.phpt | 20 | ||||
-rw-r--r-- | ext/standard/tests/strings/crc32.phpt | 16 | ||||
-rw-r--r-- | ext/standard/tests/strings/trim.phpt | 2 |
7 files changed, 104 insertions, 1 deletions
diff --git a/ext/standard/tests/strings/add-and-stripcslashes.phpt b/ext/standard/tests/strings/add-and-stripcslashes.phpt new file mode 100644 index 0000000000..35ddea763a --- /dev/null +++ b/ext/standard/tests/strings/add-and-stripcslashes.phpt @@ -0,0 +1,20 @@ +--TEST-- +addcslashes() and stripcslashes() function +--POST-- +--GET-- +--FILE-- +<?php +echo addcslashes("foobarbaz", 'bar')."\n"; +echo addcslashes('foo[ ]', 'A..z')."\n"; +echo @addcslashes("zoo['.']", 'z..A')."\n"; +echo addcslashes('abcdefghijklmnopqrstuvwxyz', "a\145..\160z")."\n"; +echo "\n\r" == stripcslashes('\n\r'),"\n"; +echo stripcslashes('\065\x64')."\n"; +?> +--EXPECT-- +foo\b\a\r\b\az +\f\o\o\[ \] +\zoo['\.'] +\abcd\e\f\g\h\i\j\k\l\m\n\o\pqrstuvwxy\z +1 +5d diff --git a/ext/standard/tests/strings/bin2hex.phpt b/ext/standard/tests/strings/bin2hex.phpt new file mode 100644 index 0000000000..5753a74dc0 --- /dev/null +++ b/ext/standard/tests/strings/bin2hex.phpt @@ -0,0 +1,16 @@ +--TEST-- +bin2hex() function +--POST-- +--GET-- +--FILE-- +<?php +$s = ''; +for($i=0; $i<256; $i++) { + $s .= chr($i); +} +echo bin2hex($s)."\n"; +echo bin2hex("abc")."\n"; +?> +--EXPECT-- +000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +616263 diff --git a/ext/standard/tests/strings/chr_ord.phpt b/ext/standard/tests/strings/chr_ord.phpt new file mode 100644 index 0000000000..266f61be04 --- /dev/null +++ b/ext/standard/tests/strings/chr_ord.phpt @@ -0,0 +1,12 @@ +--TEST-- +chr() and ord() functions +--POST-- +--GET-- +--FILE-- +<?php +echo "Testing ord() & chr()..."; +for($i=0; $i<256; $i++) echo !ord(chr($i)) == $i; +echo " done"; +?> +--EXPECT-- +Testing ord() & chr()... done diff --git a/ext/standard/tests/strings/chunk_split.phpt b/ext/standard/tests/strings/chunk_split.phpt new file mode 100644 index 0000000000..6c0f3fac84 --- /dev/null +++ b/ext/standard/tests/strings/chunk_split.phpt @@ -0,0 +1,19 @@ +--TEST-- +chunk_split() function +--POST-- +--GET-- +--FILE-- +<?php +echo chunk_split('abc', 1, '-')."\n"; +echo chunk_split('foooooooooooooooo', 5)."\n"; +echo chunk_split(str_repeat('X', 2*76))."\n"; +?> +--EXPECT-- +a-b-c- +foooo +ooooo +ooooo +oo + +XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/ext/standard/tests/strings/count_chars.phpt b/ext/standard/tests/strings/count_chars.phpt new file mode 100644 index 0000000000..0006b4232f --- /dev/null +++ b/ext/standard/tests/strings/count_chars.phpt @@ -0,0 +1,20 @@ +--TEST-- +count_chars() function +--POST-- +--GET-- +--FILE-- +<?php +$s = "het leven is net erwtensoep - je kunt er geen touw aan vastknopen"; +for($i=0; $i<3; $i++) { + echo implode(count_chars($s, $i))."\n"; +} +echo $a = count_chars($s, 3), "\n"; +echo (int) strlen(count_chars($s, 4)) == 256-strlen($a),"\n"; + +?> +--EXPECT-- +000000000000000000000000000000001200000000000010000000000000000000000000000000000000000000000000003000120111121083202362220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +121312111121832236222 +000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + -aeghijklnoprstuvw +1 diff --git a/ext/standard/tests/strings/crc32.phpt b/ext/standard/tests/strings/crc32.phpt new file mode 100644 index 0000000000..0234c0dd8d --- /dev/null +++ b/ext/standard/tests/strings/crc32.phpt @@ -0,0 +1,16 @@ +--TEST-- +crc32() function +--POST-- +--GET-- +--FILE-- +<?php +$input = array("foo", "bar", "baz", "grldsajkopallkjasd"); +foreach($input AS $i) { + echo crc32($i)."\n"; +} +?> +--EXPECT-- +-1938594527 +1996459178 +2015626392 +824412087 diff --git a/ext/standard/tests/strings/trim.phpt b/ext/standard/tests/strings/trim.phpt index 9e9143ca13..881064d7e4 100644 --- a/ext/standard/tests/strings/trim.phpt +++ b/ext/standard/tests/strings/trim.phpt @@ -1,5 +1,5 @@ --TEST-- -trim() function +trim(), rtrim() and ltrim() functions --POST-- --GET-- --FILE-- |