Permalink
Browse files

Add some test

  • Loading branch information...
1 parent 30d2db0 commit 9e7d9965946da9bff898b572a54725c15680b414 @northox committed Mar 19, 2012
Showing with 34 additions and 8 deletions.
  1. +12 −2 README.md
  2. +2 −6 StupidPass.class.php
  3. +20 −0 test.php
View
14 README.md
@@ -48,9 +48,19 @@ The most complex usage could look like this:
}
}
-# Todo
+# Test
-* Post some test.
+Let's take the most common passwords
+
+ $ php test.php
+ FAIL: football
+ FAIL: fOOtb4ll
+ FAIL: pr1nce55
+ FAIL: b4byg1r1
+ FAIL: passw0rd
+ FAIL: P@ssw0rd
+ FAIL: zxcasdqwe
+ FAIL: zxc45dqw3
# License
BSD license. In other word it's free software, free as in free beer.
View
8 StupidPass.class.php
@@ -173,12 +173,8 @@ private function expand(&$map, $old = array(), $index = 0) {
}
}
unset($old);
- if($index == count($map)-1) {
- return $new;
- } else {
- $index++;
- return $this->expand($map, $new, $index);
- }
+ $r = ($index == count($map)-1) ? $new : $this->expand($map, $new, $index + 1);
+ return $r;
}
}
?>
View
20 test.php
@@ -0,0 +1,20 @@
+<?php
+// Test Stupid Password
+require('StupidPass.class.php');
+$list = array(
+'football',
+'fOOtb4ll',
+'pr1nce55',
+'b4byg1r1',
+'passw0rd',
+'P@ssw0rd',
+'zxcasdqwe',
+'zxc45dqw3'
+);
+
+$sp = new StupidPass();
+foreach ($list as $pass) {
+ $m = ($sp->validate($pass) == false) ? "FAIL: " : "PASS: ";
+ print("$m $pass\n");
+}
+?>

0 comments on commit 9e7d996

Please sign in to comment.