ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 151 of file UtfNormalTest.php.

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

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

◆ testCleanUp()

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

Definition at line 201 of file UtfNormalTest.php.

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

Referenced by testNormals().

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

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

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

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

Referenced by testNormals().

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

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

Referenced by testNormals().

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

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

Referenced by testNormals().

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

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

Referenced by testNormals().

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

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

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

References $ok, $result, and $verbose.

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

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

Variable Documentation

◆ $failure

◆ $in

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

Definition at line 65 of file UtfNormalTest.php.

◆ $normalizer

if (! $in) $normalizer = new UtfNormal

Definition at line 73 of file UtfNormalTest.php.

◆ $ok

$ok = true

Definition at line 78 of file UtfNormalTest.php.

Referenced by ilBookmarkImportExport\__parseNetscape(), HTMLPurifier_Injector_AutoParagraph\_pLookAhead(), ilDBGenerator\buildDBGenerationScript(), ilShibbolethRoleAssignmentRules\callPlugin(), ilLDAPRoleAssignmentRules\callPlugin(), ilMailQuickFilterInputGUI\checkInput(), ilLuceneQueryInputGUI\checkInput(), ilRadioGroupInputGUI\checkInput(), ilCheckboxInputGUI\checkInput(), ilCheckboxGroupInputGUI\checkInput(), ilPropertyFormGUI\checkInput(), ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilSoapUtils\distributeMails(), Symfony\Component\Process\Process\doSignal(), 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(), 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 76 of file UtfNormalTest.php.

Referenced by reportResults().

◆ $testedChars

$testedChars = array()

Definition at line 79 of file UtfNormalTest.php.

◆ $total

$total = 0

Definition at line 75 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'
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 110 of file UtfNormalTest.php.