ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
UtfNormalTest.php File Reference

Go to the source code of this file.

Functions

 reportResults (&$total, &$success, &$failure)
 
 testNormals (&$u, $c, $comment, $reportFailure=false)
 
 verbosify ($a, $b, $col, $form, $verbose)
 
 testNFC (&$u, $c, $comment, $verbose)
 
 testCleanUp (&$u, $c, $comment, $verbose)
 
 testNFD (&$u, $c, $comment, $verbose)
 
 testNFKC (&$u, $c, $comment, $verbose)
 
 testNFKD (&$u, $c, $comment, $verbose)
 
 testInvariant (&$u, $char, $desc, $reportFailure=false)
 

Variables

 $verbose = true
 
if(defined('PRETTY_UTF8')) else
 
if(php_sapi_name() !='cli') $in = fopen("NormalizationTest.txt", "rt")
 
if(! $in) $normalizer = new UtfNormal
 
 $total = 0
 
 $success = 0
 
 $failure = 0
 
 $ok = true
 
 $testedChars = array()
 
if(! $in) print Now testing invariants n
 

Function Documentation

◆ reportResults()

reportResults ( $total,
$success,
$failure 
)

Definition at line 159 of file UtfNormalTest.php.

References $failure, $ok, $success, and $total.

160 {
161  $percSucc = intval($success * 100 / $total);
162  $percFail = intval($failure * 100 / $total);
163  print "\n";
164  print "$success tests successful ($percSucc%)\n";
165  print "$failure tests failed ($percFail%)\n\n";
166  $ok = ($success > 0 && $failure == 0);
167  $total = 0;
168  $success = 0;
169  $failure = 0;
170  return $ok;
171 }
$failure
$success
$total

◆ testCleanUp()

testCleanUp ( $u,
  $c,
  $comment,
  $verbose 
)

Definition at line 213 of file UtfNormalTest.php.

References $result, $verbose, $x, and verbosify().

Referenced by testNormals().

214 {
215  $x = $c[1];
216  $result = verbosify($c[2], $u->cleanUp($x), 1, 'cleanUp', $verbose);
217  $x = $c[2];
218  $result = verbosify($c[2], $u->cleanUp($x), 2, 'cleanUp', $verbose) && $result;
219  $x = $c[3];
220  $result = verbosify($c[2], $u->cleanUp($x), 3, 'cleanUp', $verbose) && $result;
221  $x = $c[4];
222  $result = verbosify($c[4], $u->cleanUp($x), 4, 'cleanUp', $verbose) && $result;
223  $x = $c[5];
224  $result = verbosify($c[4], $u->cleanUp($x), 5, 'cleanUp', $verbose) && $result;
225  return $result;
226 }
$result
$x
Definition: example_009.php:98
$verbose
verbosify($a, $b, $col, $form, $verbose)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testInvariant()

testInvariant ( $u,
  $char,
  $desc,
  $reportFailure = false 
)

Definition at line 258 of file UtfNormalTest.php.

References $result, $verbose, and verbosify().

259 {
260  $result = verbosify($char, $u->toNFC($char), 1, 'NFC', $reportFailure);
261  $result = verbosify($char, $u->toNFD($char), 1, 'NFD', $reportFailure) && $result;
262  $result = verbosify($char, $u->toNFKC($char), 1, 'NFKC', $reportFailure) && $result;
263  $result = verbosify($char, $u->toNFKD($char), 1, 'NFKD', $reportFailure) && $result;
264  $result = verbosify($char, $u->cleanUp($char), 1, 'cleanUp', $reportFailure) && $result;
265  global $verbose;
266  if ($verbose && !$result && !$reportFailure) {
267  print $desc;
268  testInvariant($u, $char, $desc, true);
269  }
270  return $result;
271 }
$result
testInvariant(&$u, $char, $desc, $reportFailure=false)
$verbose
verbosify($a, $b, $col, $form, $verbose)
+ Here is the call graph for this function:

◆ testNFC()

testNFC ( $u,
  $c,
  $comment,
  $verbose 
)

Definition at line 203 of file UtfNormalTest.php.

References $result, $verbose, and verbosify().

Referenced by testNormals().

204 {
205  $result = verbosify($c[2], $u->toNFC($c[1]), 1, 'NFC', $verbose);
206  $result = verbosify($c[2], $u->toNFC($c[2]), 2, 'NFC', $verbose) && $result;
207  $result = verbosify($c[2], $u->toNFC($c[3]), 3, 'NFC', $verbose) && $result;
208  $result = verbosify($c[4], $u->toNFC($c[4]), 4, 'NFC', $verbose) && $result;
209  $result = verbosify($c[4], $u->toNFC($c[5]), 5, 'NFC', $verbose) && $result;
210  return $result;
211 }
$result
$verbose
verbosify($a, $b, $col, $form, $verbose)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testNFD()

testNFD ( $u,
  $c,
  $comment,
  $verbose 
)

Definition at line 228 of file UtfNormalTest.php.

References $result, $verbose, and verbosify().

Referenced by testNormals().

229 {
230  $result = verbosify($c[3], $u->toNFD($c[1]), 1, 'NFD', $verbose);
231  $result = verbosify($c[3], $u->toNFD($c[2]), 2, 'NFD', $verbose) && $result;
232  $result = verbosify($c[3], $u->toNFD($c[3]), 3, 'NFD', $verbose) && $result;
233  $result = verbosify($c[5], $u->toNFD($c[4]), 4, 'NFD', $verbose) && $result;
234  $result = verbosify($c[5], $u->toNFD($c[5]), 5, 'NFD', $verbose) && $result;
235  return $result;
236 }
$result
$verbose
verbosify($a, $b, $col, $form, $verbose)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testNFKC()

testNFKC ( $u,
  $c,
  $comment,
  $verbose 
)

Definition at line 238 of file UtfNormalTest.php.

References $result, $verbose, and verbosify().

Referenced by testNormals().

239 {
240  $result = verbosify($c[4], $u->toNFKC($c[1]), 1, 'NFKC', $verbose);
241  $result = verbosify($c[4], $u->toNFKC($c[2]), 2, 'NFKC', $verbose) && $result;
242  $result = verbosify($c[4], $u->toNFKC($c[3]), 3, 'NFKC', $verbose) && $result;
243  $result = verbosify($c[4], $u->toNFKC($c[4]), 4, 'NFKC', $verbose) && $result;
244  $result = verbosify($c[4], $u->toNFKC($c[5]), 5, 'NFKC', $verbose) && $result;
245  return $result;
246 }
$result
$verbose
verbosify($a, $b, $col, $form, $verbose)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testNFKD()

testNFKD ( $u,
  $c,
  $comment,
  $verbose 
)

Definition at line 248 of file UtfNormalTest.php.

References $result, $verbose, and verbosify().

Referenced by testNormals().

249 {
250  $result = verbosify($c[5], $u->toNFKD($c[1]), 1, 'NFKD', $verbose);
251  $result = verbosify($c[5], $u->toNFKD($c[2]), 2, 'NFKD', $verbose) && $result;
252  $result = verbosify($c[5], $u->toNFKD($c[3]), 3, 'NFKD', $verbose) && $result;
253  $result = verbosify($c[5], $u->toNFKD($c[4]), 4, 'NFKD', $verbose) && $result;
254  $result = verbosify($c[5], $u->toNFKD($c[5]), 5, 'NFKD', $verbose) && $result;
255  return $result;
256 }
$result
$verbose
verbosify($a, $b, $col, $form, $verbose)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testNormals()

testNormals ( $u,
  $c,
  $comment,
  $reportFailure = false 
)

Definition at line 173 of file UtfNormalTest.php.

References $comment, $result, $verbose, testCleanUp(), testNFC(), testNFD(), testNFKC(), and testNFKD().

174 {
175  $result = testNFC($u, $c, $comment, $reportFailure);
176  $result = testNFD($u, $c, $comment, $reportFailure) && $result;
177  $result = testNFKC($u, $c, $comment, $reportFailure) && $result;
178  $result = testNFKD($u, $c, $comment, $reportFailure) && $result;
179  $result = testCleanUp($u, $c, $comment, $reportFailure) && $result;
180 
181  global $verbose;
182  if ($verbose && !$result && !$reportFailure) {
183  print $comment;
184  testNormals($u, $c, $comment, true);
185  }
186  return $result;
187 }
testNFD(&$u, $c, $comment, $verbose)
$result
testNormals(&$u, $c, $comment, $reportFailure=false)
$verbose
testNFKC(&$u, $c, $comment, $verbose)
testNFC(&$u, $c, $comment, $verbose)
$comment
Definition: buildRTE.php:83
testNFKD(&$u, $c, $comment, $verbose)
testCleanUp(&$u, $c, $comment, $verbose)
+ Here is the call graph for this function:

◆ verbosify()

verbosify (   $a,
  $b,
  $col,
  $form,
  $verbose 
)

Definition at line 189 of file UtfNormalTest.php.

References $ok, $result, and $verbose.

Referenced by testCleanUp(), testInvariant(), testNFC(), testNFD(), testNFKC(), and testNFKD().

190 {
191  #$result = ($a === $b);
192  $result = (strcmp($a, $b) == 0);
193  if ($verbose) {
194  $aa = pretty($a);
195  $bb = pretty($b);
196  $ok = $result ? "succeed" : " failed";
197  $eq = $result ? "==" : "!=";
198  print " $ok $form c$col '$aa' $eq '$bb'\n";
199  }
200  return $result;
201 }
$result
$verbose
+ Here is the caller graph for this function:

Variable Documentation

◆ $failure

◆ $in

$in = fopen("NormalizationTest.txt", "rt")

Definition at line 67 of file UtfNormalTest.php.

◆ $normalizer

if (! $in) $normalizer = new UtfNormal

Definition at line 75 of file UtfNormalTest.php.

◆ $ok

$ok = true

Definition at line 80 of file UtfNormalTest.php.

Referenced by ilBookmarkImportExport\__parseNetscape(), HTMLPurifier_Injector_AutoParagraph\_pLookAhead(), ilLTIToolProvider\authenticate(), OAuthSignatureMethod_RSA_SHA1\build_signature(), ilDBGenerator\buildDBGenerationScript(), ilShibbolethRoleAssignmentRules\callPlugin(), ilLDAPRoleAssignmentRules\callPlugin(), OAuthSignatureMethod_RSA_SHA1\check_signature(), ilPCMediaObjectGUI\checkFixSize(), ilLTIToolProvider\checkForShare(), ilMailQuickFilterInputGUI\checkInput(), ilLuceneQueryInputGUI\checkInput(), ilRadioGroupInputGUI\checkInput(), ilCheckboxGroupInputGUI\checkInput(), ilCheckboxInputGUI\checkInput(), ilPropertyFormGUI\checkInput(), ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilLTIToolProvider\checkValue(), IMSGlobal\LTI\ToolProvider\ResourceLink\checkValueType(), IMSGlobal\LTI\ToolProvider\User\delete(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo_sqlite\deleteContext(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\deleteContext(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\deleteContext(), ilLTIDataConnector\deleteContext(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\deleteResourceLink(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\deleteResourceLink(), ilLTIDataConnector\deleteResourceLink(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\deleteResourceLinkShareKey(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\deleteResourceLinkShareKey(), ilLTIDataConnector\deleteResourceLinkShareKey(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo_sqlite\deleteToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\deleteToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\deleteToolConsumer(), ilLTIDataConnector\deleteToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\deleteUser(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\deleteUser(), ilLTIDataConnector\deleteUser(), ilSoapUtils\distributeMails(), IMSGlobal\LTI\ToolProvider\ResourceLink\doLTI11Service(), IMSGlobal\LTI\ToolProvider\ResourceLink\doMembershipsService(), IMSGlobal\LTI\ToolProvider\ResourceLink\doService(), HTMLPurifier_Strategy_RemoveForeignElements\execute(), HTMLPurifier_Strategy_MakeWellFormed\execute(), ilUtil\extractParameterString(), ilLDAPRoleAssignmentRules\getAdditionalPluginAttributes(), SeqTreeBuilder\getAuxResources(), IMSGlobal\LTI\ToolProvider\ToolConsumer\getIsAvailable(), SeqTreeBuilder\getObjectives(), SeqTreeBuilder\getRollupRules(), assLongMenuGUI\getSelectGapTemplate(), SeqTreeBuilder\getSequencingRules(), assSingleChoiceGUI\getSolutionOutput(), assMultipleChoiceGUI\getSolutionOutput(), assMatchingQuestionGUI\getSolutionOutput(), assLongMenuGUI\getTextGapTemplate(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\getToolConsumers(), ilLTIToolProvider\handleRequest(), IMSGlobal\LTI\ToolProvider\ToolProxy\load(), IMSGlobal\LTI\ToolProvider\ToolConsumer\load(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\loadConsumerNonce(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\loadConsumerNonce(), ilLTIDataConnector\loadConsumerNonce(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\loadContext(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\loadContext(), ilLTIDataConnector\loadContext(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\loadResourceLink(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\loadResourceLink(), ilLTIDataConnector\loadResourceLink(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\loadResourceLinkShareKey(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\loadResourceLinkShareKey(), ilLTIDataConnector\loadResourceLinkShareKey(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\loadToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\loadToolConsumer(), ilLTIDataConnector\loadToolConsumer(), ilLTIDataConnector\loadToolConsumerILIAS(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\loadUser(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\loadUser(), ilLTIDataConnector\loadUser(), IMSGlobal\LTI\ToolProvider\OAuthDataStore\lookup_nonce(), ilLTIToolProvider\onError(), ilObjectListGUI\parseConditions(), HTMLPurifier_HTMLModuleManager\registerModule(), reportResults(), ilLTIToolProvider\result(), IMSGlobal\LTI\ToolProvider\Context\save(), IMSGlobal\LTI\ToolProvider\User\save(), IMSGlobal\LTI\ToolProvider\ToolConsumer\save(), IMSGlobal\LTI\ToolProvider\ResourceLink\save(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\saveConsumerNonce(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\saveConsumerNonce(), ilLTIDataConnector\saveConsumerNonce(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\saveContext(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\saveContext(), ilLTIDataConnector\saveContext(), ilObjContentObjectGUI\saveExportIds(), ilLTIToolConsumer\saveLTI(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\saveResourceLink(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\saveResourceLink(), ilLTIDataConnector\saveResourceLink(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\saveResourceLinkShareKey(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\saveResourceLinkShareKey(), ilLTIDataConnector\saveResourceLinkShareKey(), IMSGlobal\LTI\ToolProvider\Context\saveSettings(), IMSGlobal\LTI\ToolProvider\ToolConsumer\saveSettings(), IMSGlobal\LTI\ToolProvider\ResourceLink\saveSettings(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\saveToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\saveToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\saveUser(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\saveUser(), ilLTIDataConnector\saveUser(), ilPCDataTable\setData(), ilPCParagraph\setText(), grammarTest\testGrammar(), testLine(), IntConstraintsTest\testRestrict(), ValidationConstraintsCustomTest\testRestrict(), NotTest\testRestrict(), SequentialTest\testRestrict(), ParallelTest\testRestrict(), HTMLPurifier_AttrDef_CSS\validate(), HTMLPurifier_AttrDef_URI\validate(), php4DOMDocument\validate(), ilRadiusSettings\validateRequired(), Monolog\Handler\SocketHandler\validateTimeout(), HTMLPurifier_AttrValidator\validateToken(), and verbosify().

◆ $success

$success = 0

Definition at line 78 of file UtfNormalTest.php.

Referenced by reportResults().

◆ $testedChars

$testedChars = array()

Definition at line 81 of file UtfNormalTest.php.

◆ $total

$total = 0

Definition at line 77 of file UtfNormalTest.php.

Referenced by reportResults().

◆ $verbose

◆ else

if ( $ok) else
Initial value:
{
function pretty($string)
{
return trim(preg_replace_callback(
'/(.)/us',
function ($hit) {
return sprintf("%04X ", utf8ToCodepoint($hit[1]));
},
$string
));
}
}
if (isset($_SERVER['argv']) && in_array('--icu', $_SERVER['argv'])) {
dl('php_utfnormal.so');
}
require_once 'include/Unicode/UtfNormal.php'
utf8ToCodepoint($char)
Determine the Unicode codepoint of a single-character UTF-8 sequence.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

Definition at line 41 of file UtfNormalTest.php.

◆ n

if (! $in) print Now testing invariants n

Definition at line 116 of file UtfNormalTest.php.