summaryrefslogtreecommitdiff
path: root/ext/hash/tests
diff options
context:
space:
mode:
authorMartin Jansen <mj@php.net>2010-03-24 15:47:40 +0000
committerMartin Jansen <mj@php.net>2010-03-24 15:47:40 +0000
commit3842a993fee5324dd9bbcc879aaa880c8a43624e (patch)
treecaeb8c362c6ae39372584cda76d1c632382258ef /ext/hash/tests
parent293ba724517faf4d2f06d26b5ed0764f1c575bb3 (diff)
downloadphp-git-3842a993fee5324dd9bbcc879aaa880c8a43624e.tar.gz
Added Jenkins's one-at-a-time hash support to ext/hash.
Diffstat (limited to 'ext/hash/tests')
-rw-r--r--ext/hash/tests/hash_algos.phpt36
-rw-r--r--ext/hash/tests/joaat.phpt34
2 files changed, 55 insertions, 15 deletions
diff --git a/ext/hash/tests/hash_algos.phpt b/ext/hash/tests/hash_algos.phpt
index 9818dfc958..f497dfe6e7 100644
--- a/ext/hash/tests/hash_algos.phpt
+++ b/ext/hash/tests/hash_algos.phpt
@@ -18,7 +18,7 @@ var_dump(hash_algos());
===Done===
--EXPECTF--
*** Testing hash_algos() : basic functionality ***
-array(42) {
+array(45) {
[0]=>
string(3) "md2"
[1]=>
@@ -74,34 +74,40 @@ array(42) {
[26]=>
string(7) "salsa20"
[27]=>
- string(10) "haval128,3"
+ string(6) "fnv132"
[28]=>
- string(10) "haval160,3"
+ string(6) "fnv164"
[29]=>
- string(10) "haval192,3"
+ string(5) "joaat"
[30]=>
- string(10) "haval224,3"
+ string(10) "haval128,3"
[31]=>
- string(10) "haval256,3"
+ string(10) "haval160,3"
[32]=>
- string(10) "haval128,4"
+ string(10) "haval192,3"
[33]=>
- string(10) "haval160,4"
+ string(10) "haval224,3"
[34]=>
- string(10) "haval192,4"
+ string(10) "haval256,3"
[35]=>
- string(10) "haval224,4"
+ string(10) "haval128,4"
[36]=>
- string(10) "haval256,4"
+ string(10) "haval160,4"
[37]=>
- string(10) "haval128,5"
+ string(10) "haval192,4"
[38]=>
- string(10) "haval160,5"
+ string(10) "haval224,4"
[39]=>
- string(10) "haval192,5"
+ string(10) "haval256,4"
[40]=>
- string(10) "haval224,5"
+ string(10) "haval128,5"
[41]=>
+ string(10) "haval160,5"
+ [42]=>
+ string(10) "haval192,5"
+ [43]=>
+ string(10) "haval224,5"
+ [44]=>
string(10) "haval256,5"
}
===Done=== \ No newline at end of file
diff --git a/ext/hash/tests/joaat.phpt b/ext/hash/tests/joaat.phpt
new file mode 100644
index 0000000000..fa310a96e2
--- /dev/null
+++ b/ext/hash/tests/joaat.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Jenkins's one-at-a-time
+--SKIPIF--
+<?php extension_loaded('hash') or die ('Skip - hash extension not available'); ?>
+--FILE--
+<?php
+$tests = array(
+ array("hello world", "3e4a5a57"),
+ array("", 0),
+ array("", "000000"),
+ array("a", "ca2e9442"),
+ array("aa", "7081738e"),
+);
+
+$i = 0;
+$pass = true;
+
+foreach ($tests as $test) {
+ ++$i;
+
+ $result = hash("joaat", $test[0]);
+ if ($result != $test[1]) {
+ echo "Iteration " . $i . " failed - expected '" . $test[1] . "', got '" . $result . "' for '" . $test[1] . "'\n";
+
+ $pass = false;
+ }
+}
+
+if($pass) {
+ echo "PASS";
+}
+?>
+--EXPECT--
+PASS