Skip to content

Commit

Permalink
Add test for allowed characters in names
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Jan 8, 2024
1 parent 5a5dc1d commit 632c6e6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
File renamed without changes.
2 changes: 1 addition & 1 deletion rules.ini
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ idTech7 = \.streamdb$
Irrlicht = (?:^|/)Irrlicht\.dll$
Kex = \.kpf$
KiriKiri = (?:^|/)data\.xp3$
Light.vn = \.vndat$
Lightvn = \.vndat$
Lime_OR_OpenFL = (?:^|/)lime(?:-legacy)?\.[hn]dll$
Liquid = (?:^|/)PCTouchHelper\.dll$
LithTech = (?:^|/)default\.archcfg$
Expand Down
6 changes: 6 additions & 0 deletions tests/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

$FailingTests = [];
$Rulesets = parse_ini_file( __DIR__ . '/../rules.ini', true, INI_SCANNER_RAW );
$AllowedNameCharacters = '/^[a-zA-Z0-9_-]+$/';

if( empty( $Rulesets ) )
{
Expand All @@ -22,6 +23,11 @@

foreach( $Rules as $Name => $RuleRegexes )
{
if( preg_match( '/^[a-zA-Z0-9_-]+$/', $Name, $Matches ) !== 1 )
{
$FailingTests[] = "$Type.$Name has disallowed characters (allowed: {$AllowedNameCharacters})";
}

if( !is_array( $RuleRegexes ) )
{
$RuleRegexes = [ $RuleRegexes ];
Expand Down
File renamed without changes.

0 comments on commit 632c6e6

Please sign in to comment.