shein Mon, 05 Sep 2011 11:00:14 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=316153
Log: Make the test faster, what was done: 1) replaced multiple htmlentities calls with one call to get_html_translation table since they share the same code internally 2) reduced the upper range of the "for" loop to 0x2710 (10000), according to http://www.w3.org/TR/html4/sgml/entities.html it's enough 3) placed additional check to make sure all entities from get_html_translation_table were checked in the test Changed paths: U php/php-src/branches/PHP_5_3/ext/standard/tests/strings/htmlentities_html4.phpt U php/php-src/branches/PHP_5_4/ext/standard/tests/strings/htmlentities_html4.phpt U php/php-src/trunk/ext/standard/tests/strings/htmlentities_html4.phpt Modified: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/htmlentities_html4.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/htmlentities_html4.phpt 2011-09-05 10:59:26 UTC (rev 316152) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/htmlentities_html4.phpt 2011-09-05 11:00:14 UTC (rev 316153) @@ -1,9 +1,5 @@ --TEST-- htmlentities() conformance check (HTML 4) ---SKIPIF-- -<?php -if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); -?> --FILE-- <?php function utf32_utf8($k) { @@ -43,15 +39,23 @@ return $retval; } -for ($i = 0; $i < 0x110000; $i++) { +$table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, 'UTF-8'); + +for ($i = 0; $i < 0x2710; $i++) { if ($i >= 0xd800 && $i < 0xe000) continue; $str = utf32_utf8($i); - $result = htmlentities($str, ENT_QUOTES, 'UTF-8'); - if ($str != $result) { - printf("%s\tU+%05X\n", $result, $i); - } + if (isset($table[$str])) { + printf("%s\tU+%05X\n", $table[$str], $i); + unset($table[$str]); + } } + +if (!empty($table)) { + echo "Not matched entities: "; + var_dump($table); +} + ?> --EXPECT-- " U+00022 Modified: php/php-src/branches/PHP_5_4/ext/standard/tests/strings/htmlentities_html4.phpt =================================================================== --- php/php-src/branches/PHP_5_4/ext/standard/tests/strings/htmlentities_html4.phpt 2011-09-05 10:59:26 UTC (rev 316152) +++ php/php-src/branches/PHP_5_4/ext/standard/tests/strings/htmlentities_html4.phpt 2011-09-05 11:00:14 UTC (rev 316153) @@ -1,9 +1,5 @@ --TEST-- htmlentities() conformance check (HTML 4) ---SKIPIF-- -<?php -if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); -?> --FILE-- <?php function utf32_utf8($k) { @@ -43,15 +39,23 @@ return $retval; } -for ($i = 0; $i < 0x110000; $i++) { +$table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, 'UTF-8'); + +for ($i = 0; $i < 0x2710; $i++) { if ($i >= 0xd800 && $i < 0xe000) continue; $str = utf32_utf8($i); - $result = htmlentities($str, ENT_QUOTES, 'UTF-8'); - if ($str != $result) { - printf("%s\tU+%05X\n", $result, $i); - } + if (isset($table[$str])) { + printf("%s\tU+%05X\n", $table[$str], $i); + unset($table[$str]); + } } + +if (!empty($table)) { + echo "Not matched entities: "; + var_dump($table); +} + ?> --EXPECT-- " U+00022 Modified: php/php-src/trunk/ext/standard/tests/strings/htmlentities_html4.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/strings/htmlentities_html4.phpt 2011-09-05 10:59:26 UTC (rev 316152) +++ php/php-src/trunk/ext/standard/tests/strings/htmlentities_html4.phpt 2011-09-05 11:00:14 UTC (rev 316153) @@ -1,9 +1,5 @@ --TEST-- htmlentities() conformance check (HTML 4) ---SKIPIF-- -<?php -if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); -?> --FILE-- <?php function utf32_utf8($k) { @@ -43,15 +39,23 @@ return $retval; } -for ($i = 0; $i < 0x110000; $i++) { +$table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, 'UTF-8'); + +for ($i = 0; $i < 0x2710; $i++) { if ($i >= 0xd800 && $i < 0xe000) continue; $str = utf32_utf8($i); - $result = htmlentities($str, ENT_QUOTES, 'UTF-8'); - if ($str != $result) { - printf("%s\tU+%05X\n", $result, $i); - } + if (isset($table[$str])) { + printf("%s\tU+%05X\n", $table[$str], $i); + unset($table[$str]); + } } + +if (!empty($table)) { + echo "Not matched entities: "; + var_dump($table); +} + ?> --EXPECT-- " U+00022
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php