xref: /PHP-7.4/ext/hash/tests/hash_equals.phpt (revision f73c0102)
1--TEST--
2Hash: hash_equals() test
3--FILE--
4<?php
5var_dump(hash_equals("same", "same"));
6var_dump(hash_equals("not1same", "not2same"));
7var_dump(hash_equals("short", "longer"));
8var_dump(hash_equals("longer", "short"));
9var_dump(hash_equals("", "notempty"));
10var_dump(hash_equals("notempty", ""));
11var_dump(hash_equals("", ""));
12var_dump(hash_equals(123, "NaN"));
13var_dump(hash_equals("NaN", 123));
14var_dump(hash_equals(123, 123));
15var_dump(hash_equals(null, ""));
16var_dump(hash_equals(null, 123));
17var_dump(hash_equals(null, null));
18?>
19--EXPECTF--
20bool(true)
21bool(false)
22bool(false)
23bool(false)
24bool(false)
25bool(false)
26bool(true)
27
28Warning: hash_equals(): Expected known_string to be a string, int given in %s on line %d
29bool(false)
30
31Warning: hash_equals(): Expected user_string to be a string, int given in %s on line %d
32bool(false)
33
34Warning: hash_equals(): Expected known_string to be a string, int given in %s on line %d
35bool(false)
36
37Warning: hash_equals(): Expected known_string to be a string, null given in %s on line %d
38bool(false)
39
40Warning: hash_equals(): Expected known_string to be a string, null given in %s on line %d
41bool(false)
42
43Warning: hash_equals(): Expected known_string to be a string, null given in %s on line %d
44bool(false)
45