From 3247a9c40b4891a0a6fca9d0ab12a1f6e479e649 Mon Sep 17 00:00:00 2001 From: andy wharmby Date: Wed, 7 Jan 2009 14:33:00 +0000 Subject: [PATCH] New hash extension tests. Tested on Windows, Linux and Linux 64-bit --- ext/hash/tests/hash_algos.phpt | 101 ++++++++++++++++++++++ ext/hash/tests/hash_error.phpt | 48 +++++++++++ ext/hash/tests/hash_file_basic1.phpt | 87 +++++++++++++++++++ ext/hash/tests/hash_file_error1.phpt | 52 ++++++++++++ ext/hash/tests/hash_hmac_basic.phpt | 68 +++++++++++++++ ext/hash/tests/hash_hmac_error.phpt | 55 ++++++++++++ ext/hash/tests/hash_hmac_file_basic.phpt | 103 +++++++++++++++++++++++ ext/hash/tests/hash_hmac_file_error.phpt | 56 ++++++++++++ 8 files changed, 570 insertions(+) create mode 100644 ext/hash/tests/hash_algos.phpt create mode 100644 ext/hash/tests/hash_error.phpt create mode 100644 ext/hash/tests/hash_file_basic1.phpt create mode 100644 ext/hash/tests/hash_file_error1.phpt create mode 100644 ext/hash/tests/hash_hmac_basic.phpt create mode 100644 ext/hash/tests/hash_hmac_error.phpt create mode 100644 ext/hash/tests/hash_hmac_file_basic.phpt create mode 100644 ext/hash/tests/hash_hmac_file_error.phpt diff --git a/ext/hash/tests/hash_algos.phpt b/ext/hash/tests/hash_algos.phpt new file mode 100644 index 0000000000..01a664a70f --- /dev/null +++ b/ext/hash/tests/hash_algos.phpt @@ -0,0 +1,101 @@ +--TEST-- +Test hash_algos() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing hash_algos() : basic functionality *** +array(38) { + [0]=> + string(3) "md2" + [1]=> + string(3) "md4" + [2]=> + string(3) "md5" + [3]=> + string(4) "sha1" + [4]=> + string(6) "sha256" + [5]=> + string(6) "sha384" + [6]=> + string(6) "sha512" + [7]=> + string(9) "ripemd128" + [8]=> + string(9) "ripemd160" + [9]=> + string(9) "ripemd256" + [10]=> + string(9) "ripemd320" + [11]=> + string(9) "whirlpool" + [12]=> + string(10) "tiger128,3" + [13]=> + string(10) "tiger160,3" + [14]=> + string(10) "tiger192,3" + [15]=> + string(10) "tiger128,4" + [16]=> + string(10) "tiger160,4" + [17]=> + string(10) "tiger192,4" + [18]=> + string(6) "snefru" + [19]=> + string(4) "gost" + [20]=> + string(7) "adler32" + [21]=> + string(5) "crc32" + [22]=> + string(6) "crc32b" + [23]=> + string(10) "haval128,3" + [24]=> + string(10) "haval160,3" + [25]=> + string(10) "haval192,3" + [26]=> + string(10) "haval224,3" + [27]=> + string(10) "haval256,3" + [28]=> + string(10) "haval128,4" + [29]=> + string(10) "haval160,4" + [30]=> + string(10) "haval192,4" + [31]=> + string(10) "haval224,4" + [32]=> + string(10) "haval256,4" + [33]=> + string(10) "haval128,5" + [34]=> + string(10) "haval160,5" + [35]=> + string(10) "haval192,5" + [36]=> + string(10) "haval224,5" + [37]=> + string(10) "haval256,5" +} +===Done=== \ No newline at end of file diff --git a/ext/hash/tests/hash_error.phpt b/ext/hash/tests/hash_error.phpt new file mode 100644 index 0000000000..1164ca706c --- /dev/null +++ b/ext/hash/tests/hash_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test hash() function : error conditions +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing hash() : error conditions *** + +-- Testing hash() function with less than expected no. of arguments -- + +Warning: hash() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: hash() expects at least 2 parameters, 1 given in %s on line %d +NULL + +-- Testing hash() function with more than expected no. of arguments -- + +Warning: hash() expects at most 3 parameters, 4 given in %s on line %d +NULL + +-- Testing hash() function with invalid hash algorithm -- + +Warning: hash(): Unknown hashing algorithm: foo in %s on line %d +bool(false) +===Done=== \ No newline at end of file diff --git a/ext/hash/tests/hash_file_basic1.phpt b/ext/hash/tests/hash_file_basic1.phpt new file mode 100644 index 0000000000..4bbdeaffb9 --- /dev/null +++ b/ext/hash/tests/hash_file_basic1.phpt @@ -0,0 +1,87 @@ +--TEST-- +Test hash_file() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing hash_file() : basic functionality *** +adler32: 2e2287ff +crc32: 61664d33 +gost: d9e65f0c0c2ef944e4f8a01f4a46365c4f33a2853756878182a7f03e1490a4cd +haval128,3: 8bb81269aca8b7f87829020d76a4e841 +md2: 70f791c0d8fa9edd7d08e32fcba8c354 +md4: a9d034b16bb290c57a645afd6f14cd3b +md5: 704bf818448f5bbb94061332d2c889aa +ripemd128: d02a5f320a11c54c7d51f933b0bd8471 +ripemd160: 3ff296ca6314313af3ed0437c8fc0ebbd3242d3b +ripemd256: 0edd779587c11cf32781111b264251eb37529832fb207121cd45dd95002e48a8 +ripemd320: bf162fa2ff20491b3016c5d8190f8ee47d7dcda8c38eaf6779349a243a029d275eec9adf16ec1b35 +sha1: 8529b266611e3bd0d208fd9614653c2a8f23d0fe +sha256: a0f5702fa5d3670b80033d668e8732b70550392abb53841355447f8bb0f72245 +sha384: a35d875ed96d94b6452acad910f97978200faa2398d8a0e6b9cffa33704c3809e3d2e5b0d63700d8f32a0716e7d2d528 +sha512: 1f42adaf938fbf136e381b164bae5f984c7f9fe60c82728bd889c14f187c7d63e81a0305a1731c7e0a8f3ed9fd2ec92a3833a93502bdf269532601f0b8e2bab0 +snefru: d414b2345d3e7fa1a31c044cf334bfc1fec24d89e464411998d579d24663895f +tiger192,3: c6fa75a0be4ecf7afa3cafb4e2a08efc3a40534c0e46b971 +whirlpool: 4248b149e000477269a4a5f1a84d97cfc3d0199b7aaf505913e6f010a6f83276029d11a9ad545374bc710eb59c7d958985023ab886ffa9ec9a23852844c764ec +adler32(raw): 2e2287ff +md5(raw): 704bf818448f5bbb94061332d2c889aa +sha256(raw): a0f5702fa5d3670b80033d668e8732b70550392abb53841355447f8bb0f72245 +===Done=== \ No newline at end of file diff --git a/ext/hash/tests/hash_file_error1.phpt b/ext/hash/tests/hash_file_error1.phpt new file mode 100644 index 0000000000..14bbdb18df --- /dev/null +++ b/ext/hash/tests/hash_file_error1.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test hash_file() function : error conditions +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing hash_file() : error conditions *** + +-- Testing hash_file() function with less than expected no. of arguments -- + +Warning: hash_file() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: hash_file() expects at least 2 parameters, 1 given in %s on line %d +NULL + +-- Testing hash_file() function with more than expected no. of arguments -- + +Warning: hash_file() expects at most 3 parameters, 4 given in %s on line %d +NULL + +-- Testing hash_file() function with invalid hash algorithm -- + +Warning: hash_file(): Unknown hashing algorithm: foo in %s on line %d +bool(false) +===Done=== \ No newline at end of file diff --git a/ext/hash/tests/hash_hmac_basic.phpt b/ext/hash/tests/hash_hmac_basic.phpt new file mode 100644 index 0000000000..d40e0f487d --- /dev/null +++ b/ext/hash/tests/hash_hmac_basic.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test hash_file() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing hash_hmac() : basic functionality *** +adler32: 9e033311 +crc32: 96859101 +gost: a4a3c80bdf3f8665bf07376a34dc9c1b11af7c813f4928f62e39f0c0dc564dad +haval128,3: 82cd0f4bd36729b5c80c33efa8c13ac5 +md2: 6d111dab563025e4cb5f4425c991fa12 +md4: 10cdbfe843000c623f8b8da0d5d20b0b +md5: 2a632783e2812cf23de100d7d6a463ae +ripemd128: 26c2f694a65b1928b668cf55f65529b4 +ripemd160: 4b3433ba596ec39692bb7ce760a9ee5fb818113f +ripemd256: 4e4e5ec19322895a727f272dfe68f87bc1af66cc6ce27c6c1360a5ee78a14b30 +ripemd320: f10a8ff82e828b92a5ff0a02fc9032bc61352d0d824821fc42f7e09cf5b5f41ee59fd33a730d7469 +sha1: 5bfdb62b97e2c987405463e9f7c193139c0e1fd0 +sha256: 49bde3496b9510a17d0edd8a4b0ac70148e32a1d51e881ec76faa96534125838 +sha384: b781415b856744834e532b9899e1aa0bec5a82cf09a838f0a833470468e2a42648a52428cfd9012385d04de5cd9bd122 +sha512: 7de05636b18e2b0ca3427e03f53074af3a48a7b9df226daba4f22324c570638e7d7b26430e214799c9ce0db5ee88dad3292ca0f38bf99b8eaebed59b3a9c140a +snefru: 67af483046f9cf16fe19f9087929ccfc6ad176ade3290b4d33f43e0ddb07e711 +tiger192,3: 82779797cdc439e886884953ba21fa38e35679041e95ee27 +whirlpool: 4a0f1582b21b7aff59bfba7f9c29131c69741b2ce80acdc7d314040f3b768cf5a17e30b74cceb86fbc6b34b1692e0addd5bfd7cfc043d40c0621f1b97e26fa49 +adler32(raw): 9e033311 +md5(raw): 2a632783e2812cf23de100d7d6a463ae +sha256(raw): 49bde3496b9510a17d0edd8a4b0ac70148e32a1d51e881ec76faa96534125838 +===Done=== \ No newline at end of file diff --git a/ext/hash/tests/hash_hmac_error.phpt b/ext/hash/tests/hash_hmac_error.phpt new file mode 100644 index 0000000000..2c9a9a0054 --- /dev/null +++ b/ext/hash/tests/hash_hmac_error.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test hash_hmac() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing hash_hmac() : error conditions *** + +-- Testing hash_hmac() function with less than expected no. of arguments -- + +Warning: hash_hmac() expects at least 3 parameters, 0 given in %s on line %d +NULL + +Warning: hash_hmac() expects at least 3 parameters, 1 given in %s on line %d +NULL + +Warning: hash_hmac() expects at least 3 parameters, 2 given in %s on line %d +NULL + +-- Testing hash_hmac() function with more than expected no. of arguments -- + +Warning: hash_hmac() expects at most 4 parameters, 5 given in %s on line %d +NULL + +-- Testing hash_hmac() function with invalid hash algorithm -- + +Warning: hash_hmac(): Unknown hashing algorithm: foo in %s on line %d +bool(false) +===Done=== \ No newline at end of file diff --git a/ext/hash/tests/hash_hmac_file_basic.phpt b/ext/hash/tests/hash_hmac_file_basic.phpt new file mode 100644 index 0000000000..bbd89b43b8 --- /dev/null +++ b/ext/hash/tests/hash_hmac_file_basic.phpt @@ -0,0 +1,103 @@ +--TEST-- +Test hash_hmac_file() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing hash_hmac_file() : basic functionality *** +adler32: 9f037811 +crc32: f2a60b9c +gost: 94c39a40d5db852a8dc3d24e37eebf2d53e3d711457c59cd02b614f792a9d918 +haval128,3: e8fcff647f1a675acb429130fb94a17e +md2: a685475e600314bb549ab4f33c3b27cb +md4: cbc6bff781f48f57378d3effa27553e4 +md5: 8bddf39dd1c566c27acc7fa85ec36acf +ripemd128: 03269b76bf61d508c50f038cbe9ba691 +ripemd160: 94652211292268d97eb63344a3a05d3009f9d2d3 +ripemd256: b6ab414cc1630e1e474fefa41976d252f38ca7cf401552774e71736165e512e7 +ripemd320: 71271a649265740eed4b9931417f979fd81eba6288f4e08ff2997bc3dd6858da054d53a9f1fffe8c +sha1: 7f338d17b72371091abd28f451bc8d1f3a9eb3b6 +sha256: 9135286ca4c84dec711e4b831f6cd39e672e5ff93d011321274eb76733cc1e40 +sha384: 364fdc45a4c742763366ab5d3d1c17c24057e6c3b641607a36d969f00c88da25b19c8b88c8632411e3a0a02397f88aca +sha512: d460aabdf0353655059ed0d408efa91f19c4cda46acc2a4e0adf4764b06951c899fbb2ed41519db78b58ff7be17b1b2910aebe674a56861b232143571b35c83f +snefru: 7b79787e1c1d926b6cc98327f05c5d04ba6227ab51c1398661861196016ef34c +tiger192,3: 5577f21e2af269fff41e023db30e2b01bfd8b8f669177929 +whirlpool: 37a0fbb90547690d5e5e11c046f6654ffdb7bab15e16d9d79c7d85765cc4bdcbfd9df8db7a3ce9558f3f244fead00ca29cf05297f75596555195a0683f15d69f +adler32(raw): 9f037811 +md5(raw): 8bddf39dd1c566c27acc7fa85ec36acf +sha256(raw): 9135286ca4c84dec711e4b831f6cd39e672e5ff93d011321274eb76733cc1e40 +Error cases: + +Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d + +Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d + +Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d +===Done=== \ No newline at end of file diff --git a/ext/hash/tests/hash_hmac_file_error.phpt b/ext/hash/tests/hash_hmac_file_error.phpt new file mode 100644 index 0000000000..bdc2ad1dfd --- /dev/null +++ b/ext/hash/tests/hash_hmac_file_error.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test hash_hmac_file() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing hash() : error conditions *** + +-- Testing hash_hmac_file() function with less than expected no. of arguments -- + +Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d +NULL + +Warning: hash_hmac_file() expects at least 3 parameters, 1 given in %s on line %d +NULL + +Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d +NULL + +-- Testing hash_hmac_file() function with more than expected no. of arguments -- + +Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d + +-- Testing hash_hmac_file() function with invalid hash algorithm -- + +Warning: hash_hmac_file(): Unknown hashing algorithm: foo in %s on line %d +===Done=== \ No newline at end of file -- 2.40.0