Browse Source

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
pull/12/head
Shein Alexey 15 years ago
parent
commit
fae3000d44
  1. 22
      ext/standard/tests/strings/htmlentities_html4.phpt

22
ext/standard/tests/strings/htmlentities_html4.phpt

@ -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 @@ function utf32_utf8($k) {
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--
&quot; U+00022

Loading…
Cancel
Save