ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
 

Function Documentation

◆ reportResults()

reportResults ( $total,
$success,
$failure 
)

Definition at line 144 of file UtfNormalTest.php.

144 {
145 $percSucc = intval( $success * 100 / $total );
146 $percFail = intval( $failure * 100 / $total );
147 print "\n";
148 print "$success tests successful ($percSucc%)\n";
149 print "$failure tests failed ($percFail%)\n\n";
150 $ok = ($success > 0 && $failure == 0);
151 $total = 0;
152 $success = 0;
153 $failure = 0;
154 return $ok;
155}
$failure
$total
$success
if(! $in) print

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

◆ testCleanUp()

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

Definition at line 194 of file UtfNormalTest.php.

194 {
195 $x = $c[1];
196 $result = verbosify( $c[2], $u->cleanUp( $x ), 1, 'cleanUp', $verbose );
197 $x = $c[2];
198 $result = verbosify( $c[2], $u->cleanUp( $x ), 2, 'cleanUp', $verbose ) && $result;
199 $x = $c[3];
200 $result = verbosify( $c[2], $u->cleanUp( $x ), 3, 'cleanUp', $verbose ) && $result;
201 $x = $c[4];
202 $result = verbosify( $c[4], $u->cleanUp( $x ), 4, 'cleanUp', $verbose ) && $result;
203 $x = $c[5];
204 $result = verbosify( $c[4], $u->cleanUp( $x ), 5, 'cleanUp', $verbose ) && $result;
205 return $result;
206}
$result
$verbose
verbosify( $a, $b, $col, $form, $verbose)

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

Referenced by testNormals().

+ 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 235 of file UtfNormalTest.php.

235 {
236 $result = verbosify( $char, $u->toNFC( $char ), 1, 'NFC', $reportFailure );
237 $result = verbosify( $char, $u->toNFD( $char ), 1, 'NFD', $reportFailure ) && $result;
238 $result = verbosify( $char, $u->toNFKC( $char ), 1, 'NFKC', $reportFailure ) && $result;
239 $result = verbosify( $char, $u->toNFKD( $char ), 1, 'NFKD', $reportFailure ) && $result;
240 $result = verbosify( $char, $u->cleanUp( $char ), 1, 'cleanUp', $reportFailure ) && $result;
241 global $verbose;
242 if( $verbose && !$result && !$reportFailure ) {
243 print $desc;
244 testInvariant( $u, $char, $desc, true );
245 }
246 return $result;
247}
testInvariant(&$u, $char, $desc, $reportFailure=false)

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

Referenced by testInvariant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testNFC()

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

Definition at line 185 of file UtfNormalTest.php.

185 {
186 $result = verbosify( $c[2], $u->toNFC( $c[1] ), 1, 'NFC', $verbose );
187 $result = verbosify( $c[2], $u->toNFC( $c[2] ), 2, 'NFC', $verbose ) && $result;
188 $result = verbosify( $c[2], $u->toNFC( $c[3] ), 3, 'NFC', $verbose ) && $result;
189 $result = verbosify( $c[4], $u->toNFC( $c[4] ), 4, 'NFC', $verbose ) && $result;
190 $result = verbosify( $c[4], $u->toNFC( $c[5] ), 5, 'NFC', $verbose ) && $result;
191 return $result;
192}

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

Referenced by testNormals().

+ 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 208 of file UtfNormalTest.php.

208 {
209 $result = verbosify( $c[3], $u->toNFD( $c[1] ), 1, 'NFD', $verbose );
210 $result = verbosify( $c[3], $u->toNFD( $c[2] ), 2, 'NFD', $verbose ) && $result;
211 $result = verbosify( $c[3], $u->toNFD( $c[3] ), 3, 'NFD', $verbose ) && $result;
212 $result = verbosify( $c[5], $u->toNFD( $c[4] ), 4, 'NFD', $verbose ) && $result;
213 $result = verbosify( $c[5], $u->toNFD( $c[5] ), 5, 'NFD', $verbose ) && $result;
214 return $result;
215}

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

Referenced by testNormals().

+ 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 217 of file UtfNormalTest.php.

217 {
218 $result = verbosify( $c[4], $u->toNFKC( $c[1] ), 1, 'NFKC', $verbose );
219 $result = verbosify( $c[4], $u->toNFKC( $c[2] ), 2, 'NFKC', $verbose ) && $result;
220 $result = verbosify( $c[4], $u->toNFKC( $c[3] ), 3, 'NFKC', $verbose ) && $result;
221 $result = verbosify( $c[4], $u->toNFKC( $c[4] ), 4, 'NFKC', $verbose ) && $result;
222 $result = verbosify( $c[4], $u->toNFKC( $c[5] ), 5, 'NFKC', $verbose ) && $result;
223 return $result;
224}

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

Referenced by testNormals().

+ 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 226 of file UtfNormalTest.php.

226 {
227 $result = verbosify( $c[5], $u->toNFKD( $c[1] ), 1, 'NFKD', $verbose );
228 $result = verbosify( $c[5], $u->toNFKD( $c[2] ), 2, 'NFKD', $verbose ) && $result;
229 $result = verbosify( $c[5], $u->toNFKD( $c[3] ), 3, 'NFKD', $verbose ) && $result;
230 $result = verbosify( $c[5], $u->toNFKD( $c[4] ), 4, 'NFKD', $verbose ) && $result;
231 $result = verbosify( $c[5], $u->toNFKD( $c[5] ), 5, 'NFKD', $verbose ) && $result;
232 return $result;
233}

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

Referenced by testNormals().

+ 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 157 of file UtfNormalTest.php.

157 {
158 $result = testNFC( $u, $c, $comment, $reportFailure );
159 $result = testNFD( $u, $c, $comment, $reportFailure ) && $result;
160 $result = testNFKC( $u, $c, $comment, $reportFailure ) && $result;
161 $result = testNFKD( $u, $c, $comment, $reportFailure ) && $result;
162 $result = testCleanUp( $u, $c, $comment, $reportFailure ) && $result;
163
164 global $verbose;
165 if( $verbose && !$result && !$reportFailure ) {
167 testNormals( $u, $c, $comment, true );
168 }
169 return $result;
170}
testNFC(&$u, $c, $comment, $verbose)
testNormals(&$u, $c, $comment, $reportFailure=false)
testCleanUp(&$u, $c, $comment, $verbose)
testNFKC(&$u, $c, $comment, $verbose)
testNFD(&$u, $c, $comment, $verbose)
testNFKD(&$u, $c, $comment, $verbose)
$comment
Definition: buildRTE.php:83

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

Referenced by testNormals().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verbosify()

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

Definition at line 172 of file UtfNormalTest.php.

172 {
173 #$result = ($a === $b);
174 $result = (strcmp( $a, $b ) == 0);
175 if( $verbose ) {
176 $aa = pretty( $a );
177 $bb = pretty( $b );
178 $ok = $result ? "succeed" : " failed";
179 $eq = $result ? "==" : "!=";
180 print " $ok $form c$col '$aa' $eq '$bb'\n";
181 }
182 return $result;
183}

References $ok, $result, $verbose, and print.

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

+ Here is the caller graph for this function:

Variable Documentation

◆ $failure

$failure = 0

◆ $in

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

Definition at line 58 of file UtfNormalTest.php.

◆ $normalizer

if (! $in) $normalizer = new UtfNormal

Definition at line 66 of file UtfNormalTest.php.

◆ $ok

$ok = true

Definition at line 71 of file UtfNormalTest.php.

Referenced by ilBookmarkImportExport\__parseNetscape(), ilSoapUserAdministration\__validateUserData(), HTMLPurifier_Injector_AutoParagraph\_pLookAhead(), ilShibbolethRoleAssignmentRules\callPlugin(), ilLDAPRoleAssignmentRules\callPlugin(), ilBirthdayInputGUI\checkInput(), ilCheckboxGroupInputGUI\checkInput(), ilCheckboxInputGUI\checkInput(), ilDateDurationInputGUI\checkInput(), ilPropertyFormGUI\checkInput(), ilRadioGroupInputGUI\checkInput(), ilMailQuickFilterInputGUI\checkInput(), ilLuceneQueryInputGUI\checkInput(), ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilSoapUtils\distributeMails(), HTMLPurifier_Strategy_MakeWellFormed\execute(), HTMLPurifier_Strategy_RemoveForeignElements\execute(), ilUtil\extractParameterString(), ilLDAPRoleAssignmentRules\getAdditionalPluginAttributes(), SeqTreeBuilder\getAuxResources(), ilPDSelectedItemsBlockGUI\getMembershipItemsBlockHTML(), SeqTreeBuilder\getObjectives(), SeqTreeBuilder\getRollupRules(), ilPDSelectedItemsBlockGUI\getSelectedItemsBlockHTML(), SeqTreeBuilder\getSequencingRules(), assMatchingQuestionGUI\getSolutionOutput(), assMultipleChoiceGUI\getSolutionOutput(), assOrderingQuestionGUI\getSolutionOutput(), assSingleChoiceGUI\getSolutionOutput(), 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(), HTMLPurifier_AttrValidator\validateToken(), and verbosify().

◆ $success

$success = 0

Definition at line 69 of file UtfNormalTest.php.

Referenced by reportResults().

◆ $testedChars

$testedChars = array()

Definition at line 72 of file UtfNormalTest.php.

◆ $total

$total = 0

Definition at line 68 of file UtfNormalTest.php.

Referenced by reportResults().

◆ $verbose

$verbose = true

◆ else

if ($ok) else
Initial value:
{
function pretty( $string ) {
return trim( preg_replace( '/(.)/use',
'sprintf("%04X ", utf8ToCodepoint("$1"))',
$string ) );
}
}
if( isset( $_SERVER['argv'] ) && in_array( '--icu', $_SERVER['argv'] ) ) {
dl( 'php_utfnormal.so' );
}
require_once 'UtfNormalUtil.php'

Definition at line 36 of file UtfNormalTest.php.

◆ print

if (! $in) print

Definition at line 109 of file UtfNormalTest.php.

Referenced by reportResults(), testInvariant(), testNormals(), and verbosify().