]> granicus.if.org Git - php/commitdiff
Make the test faster, what was done:
authorShein Alexey <shein@php.net>
Mon, 5 Sep 2011 11:00:14 +0000 (11:00 +0000)
committerShein Alexey <shein@php.net>
Mon, 5 Sep 2011 11:00:14 +0000 (11:00 +0000)
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

ext/standard/tests/strings/htmlentities_html4.phpt

index d7bff707fdb45051cc699f2173289f1f195f4986..22b0305ced1620448dd042357ede42b23bd5dcf8 100644 (file)
@@ -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