xref: /PHP-7.0/ext/standard/tests/strings/trim.phpt (revision d94136fc)
1--TEST--
2trim(), rtrim() and ltrim() functions
3--FILE--
4<?php
5
6$tests = <<<TESTS
7'ABC' ===  trim('ABC')
8'ABC' === ltrim('ABC')
9'ABC' === rtrim('ABC')
10'ABC' ===  trim(" \\0\\t\\nABC \\0\\t\\n")
11"ABC \\0\\t\\n" === ltrim(" \\0\\t\\nABC \\0\\t\\n")
12" \\0\\t\\nABC" === rtrim(" \\0\\t\\nABC \\0\\t\\n")
13" \\0\\t\\nABC \\0\\t\\n" ===  trim(" \\0\\t\\nABC \\0\\t\\n",'')
14" \\0\\t\\nABC \\0\\t\\n" === ltrim(" \\0\\t\\nABC \\0\\t\\n",'')
15" \\0\\t\\nABC \\0\\t\\n" === rtrim(" \\0\\t\\nABC \\0\\t\\n",'')
16"ABC\\x50\\xC1" === trim("ABC\\x50\\xC1\\x60\\x90","\\x51..\\xC0")
17"ABC\\x50" === trim("ABC\\x50\\xC1\\x60\\x90","\\x51..\\xC1")
18"ABC" === trim("ABC\\x50\\xC1\\x60\\x90","\\x50..\\xC1")
19"ABC\\x50\\xC1" === trim("ABC\\x50\\xC1\\x60\\x90","\\x51..\\xC0")
20"ABC\\x50" === trim("ABC\\x50\\xC1\\x60\\x90","\\x51..\\xC1")
21"ABC" === trim("ABC\\x50\\xC1\\x60\\x90","\\x50..\\xC1")
22TESTS;
23
24include(dirname(__FILE__) . '/../../../../tests/quicktester.inc');
25
26--EXPECT--
27OK
28