ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 152 of file UtfNormalTest.php.

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

152  {
153  $percSucc = intval( $success * 100 / $total );
154  $percFail = intval( $failure * 100 / $total );
155  print "\n";
156  print "$success tests successful ($percSucc%)\n";
157  print "$failure tests failed ($percFail%)\n\n";
158  $ok = ($success > 0 && $failure == 0);
159  $total = 0;
160  $success = 0;
161  $failure = 0;
162  return $ok;
163 }
$failure
$success
$total

◆ testCleanUp()

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

Definition at line 202 of file UtfNormalTest.php.

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

Referenced by testNormals().

202  {
203  $x = $c[1];
204  $result = verbosify( $c[2], $u->cleanUp( $x ), 1, 'cleanUp', $verbose );
205  $x = $c[2];
206  $result = verbosify( $c[2], $u->cleanUp( $x ), 2, 'cleanUp', $verbose ) && $result;
207  $x = $c[3];
208  $result = verbosify( $c[2], $u->cleanUp( $x ), 3, 'cleanUp', $verbose ) && $result;
209  $x = $c[4];
210  $result = verbosify( $c[4], $u->cleanUp( $x ), 4, 'cleanUp', $verbose ) && $result;
211  $x = $c[5];
212  $result = verbosify( $c[4], $u->cleanUp( $x ), 5, 'cleanUp', $verbose ) && $result;
213  return $result;
214 }
$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 243 of file UtfNormalTest.php.

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

243  {
244  $result = verbosify( $char, $u->toNFC( $char ), 1, 'NFC', $reportFailure );
245  $result = verbosify( $char, $u->toNFD( $char ), 1, 'NFD', $reportFailure ) && $result;
246  $result = verbosify( $char, $u->toNFKC( $char ), 1, 'NFKC', $reportFailure ) && $result;
247  $result = verbosify( $char, $u->toNFKD( $char ), 1, 'NFKD', $reportFailure ) && $result;
248  $result = verbosify( $char, $u->cleanUp( $char ), 1, 'cleanUp', $reportFailure ) && $result;
249  global $verbose;
250  if( $verbose && !$result && !$reportFailure ) {
251  print $desc;
252  testInvariant( $u, $char, $desc, true );
253  }
254  return $result;
255 }
$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 193 of file UtfNormalTest.php.

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

Referenced by testNormals().

193  {
194  $result = verbosify( $c[2], $u->toNFC( $c[1] ), 1, 'NFC', $verbose );
195  $result = verbosify( $c[2], $u->toNFC( $c[2] ), 2, 'NFC', $verbose ) && $result;
196  $result = verbosify( $c[2], $u->toNFC( $c[3] ), 3, 'NFC', $verbose ) && $result;
197  $result = verbosify( $c[4], $u->toNFC( $c[4] ), 4, 'NFC', $verbose ) && $result;
198  $result = verbosify( $c[4], $u->toNFC( $c[5] ), 5, 'NFC', $verbose ) && $result;
199  return $result;
200 }
$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 216 of file UtfNormalTest.php.

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

Referenced by testNormals().

216  {
217  $result = verbosify( $c[3], $u->toNFD( $c[1] ), 1, 'NFD', $verbose );
218  $result = verbosify( $c[3], $u->toNFD( $c[2] ), 2, 'NFD', $verbose ) && $result;
219  $result = verbosify( $c[3], $u->toNFD( $c[3] ), 3, 'NFD', $verbose ) && $result;
220  $result = verbosify( $c[5], $u->toNFD( $c[4] ), 4, 'NFD', $verbose ) && $result;
221  $result = verbosify( $c[5], $u->toNFD( $c[5] ), 5, 'NFD', $verbose ) && $result;
222  return $result;
223 }
$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 225 of file UtfNormalTest.php.

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

Referenced by testNormals().

225  {
226  $result = verbosify( $c[4], $u->toNFKC( $c[1] ), 1, 'NFKC', $verbose );
227  $result = verbosify( $c[4], $u->toNFKC( $c[2] ), 2, 'NFKC', $verbose ) && $result;
228  $result = verbosify( $c[4], $u->toNFKC( $c[3] ), 3, 'NFKC', $verbose ) && $result;
229  $result = verbosify( $c[4], $u->toNFKC( $c[4] ), 4, 'NFKC', $verbose ) && $result;
230  $result = verbosify( $c[4], $u->toNFKC( $c[5] ), 5, 'NFKC', $verbose ) && $result;
231  return $result;
232 }
$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 234 of file UtfNormalTest.php.

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

Referenced by testNormals().

234  {
235  $result = verbosify( $c[5], $u->toNFKD( $c[1] ), 1, 'NFKD', $verbose );
236  $result = verbosify( $c[5], $u->toNFKD( $c[2] ), 2, 'NFKD', $verbose ) && $result;
237  $result = verbosify( $c[5], $u->toNFKD( $c[3] ), 3, 'NFKD', $verbose ) && $result;
238  $result = verbosify( $c[5], $u->toNFKD( $c[4] ), 4, 'NFKD', $verbose ) && $result;
239  $result = verbosify( $c[5], $u->toNFKD( $c[5] ), 5, 'NFKD', $verbose ) && $result;
240  return $result;
241 }
$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 165 of file UtfNormalTest.php.

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

165  {
166  $result = testNFC( $u, $c, $comment, $reportFailure );
167  $result = testNFD( $u, $c, $comment, $reportFailure ) && $result;
168  $result = testNFKC( $u, $c, $comment, $reportFailure ) && $result;
169  $result = testNFKD( $u, $c, $comment, $reportFailure ) && $result;
170  $result = testCleanUp( $u, $c, $comment, $reportFailure ) && $result;
171 
172  global $verbose;
173  if( $verbose && !$result && !$reportFailure ) {
174  print $comment;
175  testNormals( $u, $c, $comment, true );
176  }
177  return $result;
178 }
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 180 of file UtfNormalTest.php.

References $ok, $result, and $verbose.

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

180  {
181  #$result = ($a === $b);
182  $result = (strcmp( $a, $b ) == 0);
183  if( $verbose ) {
184  $aa = pretty( $a );
185  $bb = pretty( $b );
186  $ok = $result ? "succeed" : " failed";
187  $eq = $result ? "==" : "!=";
188  print " $ok $form c$col '$aa' $eq '$bb'\n";
189  }
190  return $result;
191 }
$result
$verbose
+ Here is the caller graph for this function:

Variable Documentation

◆ $failure

◆ $in

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

Definition at line 66 of file UtfNormalTest.php.

◆ $normalizer

if (! $in) $normalizer = new UtfNormal

Definition at line 74 of file UtfNormalTest.php.

◆ $ok

$ok = true

Definition at line 79 of file UtfNormalTest.php.

Referenced by ilBookmarkImportExport\__parseNetscape(), ilSoapUserAdministration\__validateUserData(), HTMLPurifier_Injector_AutoParagraph\_pLookAhead(), ilShibbolethRoleAssignmentRules\callPlugin(), ilLDAPRoleAssignmentRules\callPlugin(), ilMailQuickFilterInputGUI\checkInput(), ilLuceneQueryInputGUI\checkInput(), ilBirthdayInputGUI\checkInput(), ilRadioGroupInputGUI\checkInput(), ilCheckboxInputGUI\checkInput(), ilCheckboxGroupInputGUI\checkInput(), ilDateDurationInputGUI\checkInput(), ilPropertyFormGUI\checkInput(), ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilSoapUtils\distributeMails(), HTMLPurifier_Strategy_RemoveForeignElements\execute(), HTMLPurifier_Strategy_MakeWellFormed\execute(), ilUtil\extractParameterString(), ilLDAPRoleAssignmentRules\getAdditionalPluginAttributes(), SeqTreeBuilder\getAuxResources(), ilPDSelectedItemsBlockGUI\getMembershipItemsBlockHTML(), SeqTreeBuilder\getObjectives(), SeqTreeBuilder\getRollupRules(), ilPDSelectedItemsBlockGUI\getSelectedItemsBlockHTML(), assLongMenuGUI\getSelectGapTemplate(), SeqTreeBuilder\getSequencingRules(), assSingleChoiceGUI\getSolutionOutput(), assMultipleChoiceGUI\getSolutionOutput(), assMatchingQuestionGUI\getSolutionOutput(), assOrderingQuestionGUI\getSolutionOutput(), assLongMenuGUI\getTextGapTemplate(), ilObjectListGUI\parseConditions(), HTMLPurifier_HTMLModuleManager\registerModule(), reportResults(), ilObjContentObjectGUI\saveExportIds(), ilPCDataTable\setData(), ilPCParagraph\setText(), testLine(), 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 77 of file UtfNormalTest.php.

Referenced by reportResults().

◆ $testedChars

$testedChars = array()

Definition at line 80 of file UtfNormalTest.php.

◆ $total

$total = 0

Definition at line 76 of file UtfNormalTest.php.

Referenced by reportResults().

◆ $verbose

$verbose = true

◆ 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 'UtfNormalUtil.php'
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
utf8ToCodepoint( $char)
Determine the Unicode codepoint of a single-character UTF-8 sequence.

Definition at line 40 of file UtfNormalTest.php.

◆ n

if (! $in) print Now testing invariants n

Definition at line 111 of file UtfNormalTest.php.