y_stringhash_tests.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. /*
  2. Legal:
  3. Version: MPL 1.1
  4. The contents of this file are subject to the Mozilla Public License Version
  5. 1.1 the "License"; you may not use this file except in compliance with
  6. the License. You may obtain a copy of the License at
  7. http://www.mozilla.org/MPL/
  8. Software distributed under the License is distributed on an "AS IS" basis,
  9. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  10. for the specific language governing rights and limitations under the
  11. License.
  12. The Original Code is the YSI framework.
  13. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  14. Portions created by the Initial Developer are Copyright C 2011
  15. the Initial Developer. All Rights Reserved.
  16. Contributors:
  17. Y_Less
  18. koolk
  19. JoeBullet/Google63
  20. g_aSlice/Slice
  21. Misiur
  22. samphunter
  23. tianmeta
  24. maddinat0r
  25. spacemud
  26. Crayder
  27. Dayvison
  28. Ahmad45123
  29. Zeex
  30. irinel1996
  31. Yiin-
  32. Chaprnks
  33. Konstantinos
  34. Masterchen09
  35. Southclaws
  36. PatchwerkQWER
  37. m0k1
  38. paulommu
  39. udan111
  40. Thanks:
  41. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  42. ZeeX - Very productive conversations.
  43. koolk - IsPlayerinAreaEx code.
  44. TheAlpha - Danish translation.
  45. breadfish - German translation.
  46. Fireburn - Dutch translation.
  47. yom - French translation.
  48. 50p - Polish translation.
  49. Zamaroht - Spanish translation.
  50. Los - Portuguese translation.
  51. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  52. me to strive to better.
  53. Pixels^ - Running XScripters where the idea was born.
  54. Matite - Pestering me to release it and using it.
  55. Very special thanks to:
  56. Thiadmer - PAWN, whose limits continue to amaze me!
  57. Kye/Kalcor - SA:MP.
  58. SA:MP Team past, present and future - SA:MP.
  59. Optional plugins:
  60. Gamer_Z - GPS.
  61. Incognito - Streamer.
  62. Me - sscanf2, fixes2, Whirlpool.
  63. */
  64. TEST__ y_stringhash__Empty()
  65. {
  66. new
  67. h0 = _H@b<>,
  68. h1 = _H@f<>,
  69. h2 = _H@a<>;
  70. ASSERT_EQ(h0, -1);
  71. ASSERT_EQ(h1, 2166136261);
  72. ASSERT_EQ(h2, 2166136261);
  73. h1 = _H@b(),
  74. h2 = _H@f(),
  75. h0 = _H@a();
  76. ASSERT_EQ(h1, -1);
  77. ASSERT_EQ(h2, 2166136261);
  78. ASSERT_EQ(h0, 2166136261);
  79. h2 = YHash("", .type = hash_bernstein),
  80. h0 = YHash("", .type = hash_fnv1),
  81. h1 = YHash("", .type = hash_fnv1a);
  82. ASSERT_EQ(h2, -1);
  83. ASSERT_EQ(h0, 2166136261);
  84. ASSERT_EQ(h1, 2166136261);
  85. h2 = _H<>,
  86. h0 = _H();
  87. ASSERT_EQ(h2, -1);
  88. ASSERT_EQ(h0, -1);
  89. }
  90. TEST__ y_stringhash__Chars0()
  91. {
  92. new
  93. hh;
  94. hh = _H<aabbccddeeff>;
  95. ASSERT_EQ(hh, YHash("aabbccddeeff", .type = hash_bernstein));
  96. hh = _H<gghhiijjkkll>;
  97. ASSERT_EQ(hh, YHash("gghhiijjkkll", .type = hash_bernstein));
  98. hh = _H<mmnnooppqqrr>;
  99. ASSERT_EQ(hh, YHash("mmnnooppqqrr", .type = hash_bernstein));
  100. hh = _H<ssttuuvvwwxx>;
  101. ASSERT_EQ(hh, YHash("ssttuuvvwwxx", .type = hash_bernstein));
  102. hh = _H<yyzz00112233>;
  103. ASSERT_EQ(hh, YHash("yyzz00112233", .type = hash_bernstein));
  104. hh = _H<445566778899>;
  105. ASSERT_EQ(hh, YHash("445566778899", .type = hash_bernstein));
  106. hh = _H<AABBCCDDEEFF>;
  107. ASSERT_EQ(hh, YHash("AABBCCDDEEFF", .type = hash_bernstein));
  108. hh = _H<GGHHIIJJKKLL>;
  109. ASSERT_EQ(hh, YHash("GGHHIIJJKKLL", .type = hash_bernstein));
  110. hh = _H<MMNNOOPPQQRR>;
  111. ASSERT_EQ(hh, YHash("MMNNOOPPQQRR", .type = hash_bernstein));
  112. hh = _H<SSTTUUVVWWXX>;
  113. ASSERT_EQ(hh, YHash("SSTTUUVVWWXX", .type = hash_bernstein));
  114. hh = _H<YYZZ @@__yh>;
  115. ASSERT_EQ(hh, YHash("YYZZ @@__yh", .type = hash_bernstein));
  116. hh = _I<aabbccddeeff>;
  117. ASSERT_EQ(hh, YHash("aabbccddeeff", .sensitive = false, .type = hash_bernstein));
  118. hh = _I<gghhiijjkkll>;
  119. ASSERT_EQ(hh, YHash("gghhiijjkkll", .sensitive = false, .type = hash_bernstein));
  120. hh = _I<mmnnooppqqrr>;
  121. ASSERT_EQ(hh, YHash("mmnnooppqqrr", .sensitive = false, .type = hash_bernstein));
  122. hh = _I<ssttuuvvwwxx>;
  123. ASSERT_EQ(hh, YHash("ssttuuvvwwxx", .sensitive = false, .type = hash_bernstein));
  124. hh = _I<yyzz00112233>;
  125. ASSERT_EQ(hh, YHash("yyzz00112233", .sensitive = false, .type = hash_bernstein));
  126. hh = _I<445566778899>;
  127. ASSERT_EQ(hh, YHash("445566778899", .sensitive = false, .type = hash_bernstein));
  128. hh = _I<AABBCCDDEEFF>;
  129. ASSERT_EQ(hh, YHash("AABBCCDDEEFF", .sensitive = false, .type = hash_bernstein));
  130. hh = _I<GGHHIIJJKKLL>;
  131. ASSERT_EQ(hh, YHash("GGHHIIJJKKLL", .sensitive = false, .type = hash_bernstein));
  132. hh = _I<MMNNOOPPQQRR>;
  133. ASSERT_EQ(hh, YHash("MMNNOOPPQQRR", .sensitive = false, .type = hash_bernstein));
  134. hh = _I<SSTTUUVVWWXX>;
  135. ASSERT_EQ(hh, YHash("SSTTUUVVWWXX", .sensitive = false, .type = hash_bernstein));
  136. hh = _I<YYZZ @@__yh>;
  137. ASSERT_EQ(hh, YHash("YYZZ @@__yh", .sensitive = false, .type = hash_bernstein));
  138. // Ignore cases.
  139. hh = _I<aabbccddeeff>;
  140. ASSERT_EQ(hh, YHash("AABBCCDDEEFF", .sensitive = false, .type = hash_bernstein));
  141. hh = _I<gghhiijjkkll>;
  142. ASSERT_EQ(hh, YHash("gghhiijjkkll", .sensitive = false, .type = hash_bernstein));
  143. hh = _I<mmnnooppqqrr>;
  144. ASSERT_EQ(hh, YHash("MMNNOOPPQQRR", .sensitive = false, .type = hash_bernstein));
  145. hh = _I<ssttuuvvwwxx>;
  146. ASSERT_EQ(hh, YHash("SSTTUUVVWWXX", .sensitive = false, .type = hash_bernstein));
  147. hh = _I<yyzz00112233>;
  148. ASSERT_EQ(hh, YHash("YYZZ00112233", .sensitive = false, .type = hash_bernstein));
  149. hh = _I<AABBCCDDEEFF>;
  150. ASSERT_EQ(hh, YHash("aabbccddeeff", .sensitive = false, .type = hash_bernstein));
  151. hh = _I<GGHHIIJJKKLL>;
  152. ASSERT_EQ(hh, YHash("GGHHIIJJKKLL", .sensitive = false, .type = hash_bernstein));
  153. hh = _I<MMNNOOPPQQRR>;
  154. ASSERT_EQ(hh, YHash("mmnnooppqqrr", .sensitive = false, .type = hash_bernstein));
  155. hh = _I<SSTTUUVVWWXX>;
  156. ASSERT_EQ(hh, YHash("ssttuuvvwwxx", .sensitive = false, .type = hash_bernstein));
  157. hh = _I<YYZZ @@__yh>;
  158. ASSERT_EQ(hh, YHash("yyzz @@__yh", .sensitive = false, .type = hash_bernstein));
  159. }
  160. TEST__ y_stringhash__Chars1()
  161. {
  162. new
  163. hh;
  164. hh = _H@f<aabbccddeeff>;
  165. ASSERT_EQ(hh, YHash("aabbccddeeff", .type = hash_fnv1));
  166. hh = _H@f<gghhiijjkkll>;
  167. ASSERT_EQ(hh, YHash("gghhiijjkkll", .type = hash_fnv1));
  168. hh = _H@f<mmnnooppqqrr>;
  169. ASSERT_EQ(hh, YHash("mmnnooppqqrr", .type = hash_fnv1));
  170. hh = _H@f<ssttuuvvwwxx>;
  171. ASSERT_EQ(hh, YHash("ssttuuvvwwxx", .type = hash_fnv1));
  172. hh = _H@f<yyzz00112233>;
  173. ASSERT_EQ(hh, YHash("yyzz00112233", .type = hash_fnv1));
  174. hh = _H@f<445566778899>;
  175. ASSERT_EQ(hh, YHash("445566778899", .type = hash_fnv1));
  176. hh = _H@f<AABBCCDDEEFF>;
  177. ASSERT_EQ(hh, YHash("AABBCCDDEEFF", .type = hash_fnv1));
  178. hh = _H@f<GGHHIIJJKKLL>;
  179. ASSERT_EQ(hh, YHash("GGHHIIJJKKLL", .type = hash_fnv1));
  180. hh = _H@f<MMNNOOPPQQRR>;
  181. ASSERT_EQ(hh, YHash("MMNNOOPPQQRR", .type = hash_fnv1));
  182. hh = _H@f<SSTTUUVVWWXX>;
  183. ASSERT_EQ(hh, YHash("SSTTUUVVWWXX", .type = hash_fnv1));
  184. hh = _H@f<YYZZ @@__yh>;
  185. ASSERT_EQ(hh, YHash("YYZZ @@__yh", .type = hash_fnv1));
  186. hh = _I@f<aabbccddeeff>;
  187. ASSERT_EQ(hh, YHash("aabbccddeeff", .sensitive = false, .type = hash_fnv1));
  188. hh = _I@f<gghhiijjkkll>;
  189. ASSERT_EQ(hh, YHash("gghhiijjkkll", .sensitive = false, .type = hash_fnv1));
  190. hh = _I@f<mmnnooppqqrr>;
  191. ASSERT_EQ(hh, YHash("mmnnooppqqrr", .sensitive = false, .type = hash_fnv1));
  192. hh = _I@f<ssttuuvvwwxx>;
  193. ASSERT_EQ(hh, YHash("ssttuuvvwwxx", .sensitive = false, .type = hash_fnv1));
  194. hh = _I@f<yyzz00112233>;
  195. ASSERT_EQ(hh, YHash("yyzz00112233", .sensitive = false, .type = hash_fnv1));
  196. hh = _I@f<445566778899>;
  197. ASSERT_EQ(hh, YHash("445566778899", .sensitive = false, .type = hash_fnv1));
  198. hh = _I@f<AABBCCDDEEFF>;
  199. ASSERT_EQ(hh, YHash("AABBCCDDEEFF", .sensitive = false, .type = hash_fnv1));
  200. hh = _I@f<GGHHIIJJKKLL>;
  201. ASSERT_EQ(hh, YHash("GGHHIIJJKKLL", .sensitive = false, .type = hash_fnv1));
  202. hh = _I@f<MMNNOOPPQQRR>;
  203. ASSERT_EQ(hh, YHash("MMNNOOPPQQRR", .sensitive = false, .type = hash_fnv1));
  204. hh = _I@f<SSTTUUVVWWXX>;
  205. ASSERT_EQ(hh, YHash("SSTTUUVVWWXX", .sensitive = false, .type = hash_fnv1));
  206. hh = _I@f<YYZZ @@__yh>;
  207. ASSERT_EQ(hh, YHash("YYZZ @@__yh", .sensitive = false, .type = hash_fnv1));
  208. // Ignore cases.
  209. hh = _I@f<aabbccddeeff>;
  210. ASSERT_EQ(hh, YHash("AABBCCDDEEFF", .sensitive = false, .type = hash_fnv1));
  211. hh = _I@f<gghhiijjkkll>;
  212. ASSERT_EQ(hh, YHash("gghhiijjkkll", .sensitive = false, .type = hash_fnv1));
  213. hh = _I@f<mmnnooppqqrr>;
  214. ASSERT_EQ(hh, YHash("MMNNOOPPQQRR", .sensitive = false, .type = hash_fnv1));
  215. hh = _I@f<ssttuuvvwwxx>;
  216. ASSERT_EQ(hh, YHash("SSTTUUVVWWXX", .sensitive = false, .type = hash_fnv1));
  217. hh = _I@f<yyzz00112233>;
  218. ASSERT_EQ(hh, YHash("YYZZ00112233", .sensitive = false, .type = hash_fnv1));
  219. hh = _I@f<AABBCCDDEEFF>;
  220. ASSERT_EQ(hh, YHash("aabbccddeeff", .sensitive = false, .type = hash_fnv1));
  221. hh = _I@f<GGHHIIJJKKLL>;
  222. ASSERT_EQ(hh, YHash("GGHHIIJJKKLL", .sensitive = false, .type = hash_fnv1));
  223. hh = _I@f<MMNNOOPPQQRR>;
  224. ASSERT_EQ(hh, YHash("mmnnooppqqrr", .sensitive = false, .type = hash_fnv1));
  225. hh = _I@f<SSTTUUVVWWXX>;
  226. ASSERT_EQ(hh, YHash("ssttuuvvwwxx", .sensitive = false, .type = hash_fnv1));
  227. hh = _I@f<YYZZ @@__yh>;
  228. ASSERT_EQ(hh, YHash("yyzz @@__yh", .sensitive = false, .type = hash_fnv1));
  229. }
  230. TEST__ y_stringhash__Chars2()
  231. {
  232. new
  233. hh;
  234. hh = _H@a<aabbccddeeff>;
  235. ASSERT_EQ(hh, YHash("aabbccddeeff", .type = hash_fnv1a));
  236. hh = _H@a<gghhiijjkkll>;
  237. ASSERT_EQ(hh, YHash("gghhiijjkkll", .type = hash_fnv1a));
  238. hh = _H@a<mmnnooppqqrr>;
  239. ASSERT_EQ(hh, YHash("mmnnooppqqrr", .type = hash_fnv1a));
  240. hh = _H@a<ssttuuvvwwxx>;
  241. ASSERT_EQ(hh, YHash("ssttuuvvwwxx", .type = hash_fnv1a));
  242. hh = _H@a<yyzz00112233>;
  243. ASSERT_EQ(hh, YHash("yyzz00112233", .type = hash_fnv1a));
  244. hh = _H@a<445566778899>;
  245. ASSERT_EQ(hh, YHash("445566778899", .type = hash_fnv1a));
  246. hh = _H@a<AABBCCDDEEFF>;
  247. ASSERT_EQ(hh, YHash("AABBCCDDEEFF", .type = hash_fnv1a));
  248. hh = _H@a<GGHHIIJJKKLL>;
  249. ASSERT_EQ(hh, YHash("GGHHIIJJKKLL", .type = hash_fnv1a));
  250. hh = _H@a<MMNNOOPPQQRR>;
  251. ASSERT_EQ(hh, YHash("MMNNOOPPQQRR", .type = hash_fnv1a));
  252. hh = _H@a<SSTTUUVVWWXX>;
  253. ASSERT_EQ(hh, YHash("SSTTUUVVWWXX", .type = hash_fnv1a));
  254. hh = _H@a<YYZZ @@__yh>;
  255. ASSERT_EQ(hh, YHash("YYZZ @@__yh", .type = hash_fnv1a));
  256. hh = _I@a<aabbccddeeff>;
  257. ASSERT_EQ(hh, YHash("aabbccddeeff", .sensitive = false, .type = hash_fnv1a));
  258. hh = _I@a<gghhiijjkkll>;
  259. ASSERT_EQ(hh, YHash("gghhiijjkkll", .sensitive = false, .type = hash_fnv1a));
  260. hh = _I@a<mmnnooppqqrr>;
  261. ASSERT_EQ(hh, YHash("mmnnooppqqrr", .sensitive = false, .type = hash_fnv1a));
  262. hh = _I@a<ssttuuvvwwxx>;
  263. ASSERT_EQ(hh, YHash("ssttuuvvwwxx", .sensitive = false, .type = hash_fnv1a));
  264. hh = _I@a<yyzz00112233>;
  265. ASSERT_EQ(hh, YHash("yyzz00112233", .sensitive = false, .type = hash_fnv1a));
  266. hh = _I@a<445566778899>;
  267. ASSERT_EQ(hh, YHash("445566778899", .sensitive = false, .type = hash_fnv1a));
  268. hh = _I@a<AABBCCDDEEFF>;
  269. ASSERT_EQ(hh, YHash("AABBCCDDEEFF", .sensitive = false, .type = hash_fnv1a));
  270. hh = _I@a<GGHHIIJJKKLL>;
  271. ASSERT_EQ(hh, YHash("GGHHIIJJKKLL", .sensitive = false, .type = hash_fnv1a));
  272. hh = _I@a<MMNNOOPPQQRR>;
  273. ASSERT_EQ(hh, YHash("MMNNOOPPQQRR", .sensitive = false, .type = hash_fnv1a));
  274. hh = _I@a<SSTTUUVVWWXX>;
  275. ASSERT_EQ(hh, YHash("SSTTUUVVWWXX", .sensitive = false, .type = hash_fnv1a));
  276. hh = _I@a<YYZZ @@__yh>;
  277. ASSERT_EQ(hh, YHash("YYZZ @@__yh", .sensitive = false, .type = hash_fnv1a));
  278. // Ignore cases.
  279. hh = _I@a<aabbccddeeff>;
  280. ASSERT_EQ(hh, YHash("AABBCCDDEEFF", .sensitive = false, .type = hash_fnv1a));
  281. hh = _I@a<gghhiijjkkll>;
  282. ASSERT_EQ(hh, YHash("gghhiijjkkll", .sensitive = false, .type = hash_fnv1a));
  283. hh = _I@a<mmnnooppqqrr>;
  284. ASSERT_EQ(hh, YHash("MMNNOOPPQQRR", .sensitive = false, .type = hash_fnv1a));
  285. hh = _I@a<ssttuuvvwwxx>;
  286. ASSERT_EQ(hh, YHash("SSTTUUVVWWXX", .sensitive = false, .type = hash_fnv1a));
  287. hh = _I@a<yyzz00112233>;
  288. ASSERT_EQ(hh, YHash("YYZZ00112233", .sensitive = false, .type = hash_fnv1a));
  289. hh = _I@a<AABBCCDDEEFF>;
  290. ASSERT_EQ(hh, YHash("aabbccddeeff", .sensitive = false, .type = hash_fnv1a));
  291. hh = _I@a<GGHHIIJJKKLL>;
  292. ASSERT_EQ(hh, YHash("GGHHIIJJKKLL", .sensitive = false, .type = hash_fnv1a));
  293. hh = _I@a<MMNNOOPPQQRR>;
  294. ASSERT_EQ(hh, YHash("mmnnooppqqrr", .sensitive = false, .type = hash_fnv1a));
  295. hh = _I@a<SSTTUUVVWWXX>;
  296. ASSERT_EQ(hh, YHash("ssttuuvvwwxx", .sensitive = false, .type = hash_fnv1a));
  297. hh = _I@a<YYZZ @@__yh>;
  298. ASSERT_EQ(hh, YHash("yyzz @@__yh", .sensitive = false, .type = hash_fnv1a));
  299. }
  300. TEST__ y_stringhash__Letters1()
  301. {
  302. new
  303. hh;
  304. hh = _I<A>;
  305. ASSERT_EQ(hh, YHash("A", .sensitive = false));
  306. hh = _I<A>;
  307. ASSERT_EQ(hh, YHash("a", .sensitive = false));
  308. hh = _I<a>;
  309. ASSERT_EQ(hh, YHash("A", .sensitive = false));
  310. hh = _I<a>;
  311. ASSERT_EQ(hh, YHash("a", .sensitive = false));
  312. hh = _I<0>;
  313. ASSERT_EQ(hh, YHash("0", .sensitive = false));
  314. hh = _I<_>;
  315. ASSERT_EQ(hh, YHash("_", .sensitive = false));
  316. hh = _I<@>;
  317. ASSERT_EQ(hh, YHash("@", .sensitive = false));
  318. }
  319. TEST__ y_stringhash__Letters2()
  320. {
  321. new
  322. hh;
  323. hh = _H<A>;
  324. ASSERT_EQ(hh, YHash("A"));
  325. hh = _H<A>;
  326. ASSERT_NE(hh, YHash("a"));
  327. hh = _H<a>;
  328. ASSERT_NE(hh, YHash("A"));
  329. hh = _H<a>;
  330. ASSERT_EQ(hh, YHash("a"));
  331. hh = _H<0>;
  332. ASSERT_EQ(hh, YHash("0"));
  333. hh = _H<_>;
  334. ASSERT_EQ(hh, YHash("_"));
  335. hh = _H<@>;
  336. ASSERT_EQ(hh, YHash("@"));
  337. }
  338. TEST__ y_stringhash__case()
  339. {
  340. new
  341. h0,
  342. h1;
  343. h0 = _H<HEllO>;
  344. h1 = _H<HELLO>;
  345. ASSERT_NE(h0, h1);
  346. h0 = _I<HEllO>;
  347. h1 = _I<HELLO>;
  348. ASSERT_EQ(h0, h1);
  349. h0 = _H@b<heLLo>;
  350. h1 = _H@b<HELLO>;
  351. ASSERT_NE(h0, h1);
  352. h0 = _I@b<heLLo>;
  353. h1 = _I@b<HELLO>;
  354. ASSERT_EQ(h0, h1);
  355. h0 = _H@f<hello>;
  356. h1 = _H@f<HELLO>;
  357. ASSERT_NE(h0, h1);
  358. h0 = _I@f<hello>;
  359. h1 = _I@f<HELLO>;
  360. ASSERT_EQ(h0, h1);
  361. h0 = _H@a<hElLo>;
  362. h1 = _H@a<HELLO>;
  363. ASSERT_NE(h0, h1);
  364. h0 = _I@a<hElLo>;
  365. h1 = _I@a<HELLO>;
  366. ASSERT_EQ(h0, h1);
  367. }
  368. TEST__ y_stringhash__H1()
  369. {
  370. new
  371. h0 = _H<hello>,
  372. h1 = _H<there>;
  373. ASSERT_NE(h0, h1);
  374. }
  375. TEST__ y_stringhash__I1()
  376. {
  377. new
  378. h0 = _I<hello>,
  379. h1 = _I<HelLo>;
  380. ASSERT_EQ(h0, h1);
  381. }
  382. TEST__ y_stringhash__H2()
  383. {
  384. new
  385. h0 = _H(h,e,l,l,o),
  386. h1 = _H(t,h,e,r,e);
  387. ASSERT_NE(h0, h1);
  388. }
  389. TEST__ y_stringhash__I2()
  390. {
  391. new
  392. h0 = _I(h,e,l,l,o),
  393. h1 = _I(H,E,L,L,O);
  394. ASSERT_EQ(h0, h1);
  395. }
  396. TEST__ y_stringhash__H3()
  397. {
  398. new
  399. h0 = _H@b<hello>,
  400. h1 = _H@b<there>;
  401. ASSERT_NE(h0, h1);
  402. }
  403. TEST__ y_stringhash__I3()
  404. {
  405. new
  406. h0 = _I@b<hello>,
  407. h1 = _I@b<HelLo>;
  408. ASSERT_EQ(h0, h1);
  409. }
  410. TEST__ y_stringhash__H4()
  411. {
  412. new
  413. h0 = _H@b(h,e,l,l,o),
  414. h1 = _H@b(t,h,e,r,e);
  415. ASSERT_NE(h0, h1);
  416. }
  417. TEST__ y_stringhash__I4()
  418. {
  419. new
  420. h0 = _I@b(h,e,l,l,o),
  421. h1 = _I@b(H,E,L,L,O);
  422. ASSERT_EQ(h0, h1);
  423. }
  424. TEST__ y_stringhash__H5()
  425. {
  426. new
  427. h0 = _H@f<hello>,
  428. h1 = _H@f<there>;
  429. ASSERT_NE(h0, h1);
  430. }
  431. TEST__ y_stringhash__I5()
  432. {
  433. new
  434. h0 = _I@f<hello>,
  435. h1 = _I@f<HelLo>;
  436. ASSERT_EQ(h0, h1);
  437. }
  438. TEST__ y_stringhash__H6()
  439. {
  440. new
  441. h0 = _H@f(h,e,l,l,o),
  442. h1 = _H@f(t,h,e,r,e);
  443. ASSERT_NE(h0, h1);
  444. }
  445. TEST__ y_stringhash__I6()
  446. {
  447. new
  448. h0 = _I@f(h,e,l,l,o),
  449. h1 = _I@f(H,E,L,L,O);
  450. ASSERT_EQ(h0, h1);
  451. }
  452. TEST__ y_stringhash__H7()
  453. {
  454. new
  455. h0 = _H@a<hello>,
  456. h1 = _H@a<there>;
  457. ASSERT_NE(h0, h1);
  458. }
  459. TEST__ y_stringhash__I7()
  460. {
  461. new
  462. h0 = _I@a<hello>,
  463. h1 = _I@a<HelLo>;
  464. ASSERT_EQ(h0, h1);
  465. }
  466. TEST__ y_stringhash__H8()
  467. {
  468. new
  469. h0 = _H@a(h,e,l,l,o),
  470. h1 = _H@a(t,h,e,r,e);
  471. ASSERT_NE(h0, h1);
  472. }
  473. TEST__ y_stringhash__I8()
  474. {
  475. new
  476. h0 = _I@a(h,e,l,l,o),
  477. h1 = _I@a(H,E,L,L,O);
  478. ASSERT_EQ(h0, h1);
  479. }
  480. TEST__ y_stringhash__H3e()
  481. {
  482. new
  483. h0 = _H@b<hello>,
  484. h1 = YHash("hello", .type = hash_bernstein);
  485. ASSERT_EQ(h0, h1);
  486. }
  487. TEST__ y_stringhash__I3e()
  488. {
  489. new
  490. h0 = _I@b<hello>,
  491. h1 = YHash("hello", .type = hash_bernstein, .sensitive = false);
  492. //printf("%04x%04x %04x%04x", h0 >>> 16, h0 & 0xFFFF, h1 >>> 16, h1 & 0xFFFF);
  493. ASSERT_EQ(h0, h1);
  494. }
  495. TEST__ y_stringhash__H4e()
  496. {
  497. new
  498. h0 = _H@b(h,e,l,l,o),
  499. h1 = YHash("hello", .type = hash_bernstein);
  500. ASSERT_EQ(h0, h1);
  501. }
  502. TEST__ y_stringhash__I4e()
  503. {
  504. new
  505. h0 = _I@b(h,e,l,l,o),
  506. h1 = YHash("hello", .type = hash_bernstein, .sensitive = false);
  507. ASSERT_EQ(h0, h1);
  508. }
  509. TEST__ y_stringhash__H5e()
  510. {
  511. new
  512. h0 = _H@f<hello>,
  513. h1 = YHash("hello", .type = hash_fnv1);
  514. ASSERT_EQ(h0, h1);
  515. }
  516. TEST__ y_stringhash__I5e()
  517. {
  518. new
  519. h0 = _I@f<hello>,
  520. h1 = YHash("hello", .type = hash_fnv1, .sensitive = false);
  521. ASSERT_EQ(h0, h1);
  522. }
  523. TEST__ y_stringhash__H6e()
  524. {
  525. new
  526. h0 = _H@f(h,e,l,l,o),
  527. h1 = YHash("hello", .type = hash_fnv1);
  528. ASSERT_EQ(h0, h1);
  529. }
  530. TEST__ y_stringhash__I6e()
  531. {
  532. new
  533. h0 = _I@f(h,e,l,l,o),
  534. h1 = YHash("hello", .type = hash_fnv1, .sensitive = false);
  535. ASSERT_EQ(h0, h1);
  536. }
  537. TEST__ y_stringhash__H7e()
  538. {
  539. new
  540. h0 = _H@a<hello>,
  541. h1 = YHash("hello", .type = hash_fnv1a);
  542. ASSERT_EQ(h0, h1);
  543. }
  544. TEST__ y_stringhash__I7e()
  545. {
  546. new
  547. h0 = _I@a<hello>,
  548. h1 = YHash("hello", .type = hash_fnv1a, .sensitive = false);
  549. ASSERT_EQ(h0, h1);
  550. }
  551. TEST__ y_stringhash__H8e()
  552. {
  553. new
  554. h0 = _H@a(h,e,l,l,o),
  555. h1 = YHash("hello", .type = hash_fnv1a);
  556. ASSERT_EQ(h0, h1);
  557. }
  558. TEST__ y_stringhash__I8e()
  559. {
  560. new
  561. h0 = _I@a(h,e,l,l,o),
  562. h1 = YHash("hello", .type = hash_fnv1a, .sensitive = false);
  563. ASSERT_EQ(h0, h1);
  564. }
  565. TEST__ y_stringhash__H3d()
  566. {
  567. new
  568. h0 = HASH:bernstein<hello>,
  569. h1 = YHash("hello", .type = hash_bernstein);
  570. ASSERT_EQ(h0, h1);
  571. }
  572. TEST__ y_stringhash__I3d()
  573. {
  574. new
  575. h0 = HASHi:bernstein<hello>,
  576. h1 = YHash("hello", .type = hash_bernstein, .sensitive = false);
  577. ASSERT_EQ(h0, h1);
  578. }
  579. TEST__ y_stringhash__H4d()
  580. {
  581. new
  582. h0 = HASH(bernstein,h,e,l,l,o),
  583. h1 = YHash("hello", .type = hash_bernstein);
  584. ASSERT_EQ(h0, h1);
  585. }
  586. TEST__ y_stringhash__I4d()
  587. {
  588. new
  589. h0 = HASHi(bernstein,h,e,l,l,o),
  590. h1 = YHash("hello", .type = hash_bernstein, .sensitive = false);
  591. ASSERT_EQ(h0, h1);
  592. }
  593. TEST__ y_stringhash__H5d()
  594. {
  595. new
  596. h0 = HASH:fnv1<hello>,
  597. h1 = YHash("hello", .type = hash_fnv1);
  598. ASSERT_EQ(h0, h1);
  599. }
  600. TEST__ y_stringhash__I5d()
  601. {
  602. new
  603. h0 = HASHi:fnv1<hello>,
  604. h1 = YHash("hello", .type = hash_fnv1, .sensitive = false);
  605. ASSERT_EQ(h0, h1);
  606. }
  607. TEST__ y_stringhash__H6d()
  608. {
  609. new
  610. h0 = HASH(fnv1,h,e,l,l,o),
  611. h1 = YHash("hello", .type = hash_fnv1);
  612. ASSERT_EQ(h0, h1);
  613. }
  614. TEST__ y_stringhash__I6d()
  615. {
  616. new
  617. h0 = HASHi(fnv1,h,e,l,l,o),
  618. h1 = YHash("hello", .type = hash_fnv1, .sensitive = false);
  619. ASSERT_EQ(h0, h1);
  620. }
  621. TEST__ y_stringhash__H7d()
  622. {
  623. new
  624. h0 = HASH:fnv1a<hello>,
  625. h1 = YHash("hello", .type = hash_fnv1a);
  626. ASSERT_EQ(h0, h1);
  627. }
  628. TEST__ y_stringhash__I7d()
  629. {
  630. new
  631. h0 = HASHi:fnv1a<hello>,
  632. h1 = YHash("hello", .type = hash_fnv1a, .sensitive = false);
  633. ASSERT_EQ(h0, h1);
  634. }
  635. TEST__ y_stringhash__H8d()
  636. {
  637. new
  638. h0 = HASH(fnv1a,h,e,l,l,o),
  639. h1 = YHash("hello", .type = hash_fnv1a);
  640. ASSERT_EQ(h0, h1);
  641. }
  642. TEST__ y_stringhash__I8d()
  643. {
  644. new
  645. h0 = HASHi(fnv1a,h,e,l,l,o),
  646. h1 = YHash("hello", .type = hash_fnv1a, .sensitive = false);
  647. ASSERT_EQ(h0, h1);
  648. }
  649. TEST__ y_stringhash__H3c()
  650. {
  651. new
  652. h0 = HASH:bernstein<hello>,
  653. h1 = _H(h,e,l,l,o);
  654. ASSERT_EQ(h0, h1);
  655. }
  656. TEST__ y_stringhash__I3c()
  657. {
  658. new
  659. h0 = HASHi:bernstein<hello>,
  660. h1 = _I(h,e,L,L,o);
  661. ASSERT_EQ(h0, h1);
  662. }
  663. TEST__ y_stringhash__H4c()
  664. {
  665. new
  666. h0 = HASH(bernstein,h,e,l,l,o),
  667. h1 = _H<hello>;
  668. ASSERT_EQ(h0, h1);
  669. }
  670. TEST__ y_stringhash__I4c()
  671. {
  672. new
  673. h0 = HASHi(bernstein,h,e,l,l,o),
  674. h1 = _I<hellO>;
  675. ASSERT_EQ(h0, h1);
  676. }
  677. TEST__ y_stringhash__H5c()
  678. {
  679. new
  680. h0 = HASH:fnv1<hello>,
  681. h1 = _H@f(h,e,l,l,o);
  682. ASSERT_EQ(h0, h1);
  683. }
  684. TEST__ y_stringhash__I5c()
  685. {
  686. new
  687. h0 = HASHi:fnv1<hello>,
  688. h1 = _I@f(h,E,l,l,o);
  689. ASSERT_EQ(h0, h1);
  690. }
  691. TEST__ y_stringhash__H6c()
  692. {
  693. new
  694. h0 = HASH(fnv1,h,e,l,l,o),
  695. h1 = _H@f<hello>;
  696. ASSERT_EQ(h0, h1);
  697. }
  698. TEST__ y_stringhash__I6c()
  699. {
  700. new
  701. h0 = HASHi(fnv1,h,e,l,l,o),
  702. h1 = _I@f<hElLO>;
  703. ASSERT_EQ(h0, h1);
  704. }
  705. TEST__ y_stringhash__H7c()
  706. {
  707. new
  708. h0 = HASH:fnv1a<hello>,
  709. h1 = _H@a(h,e,l,l,o);
  710. ASSERT_EQ(h0, h1);
  711. }
  712. TEST__ y_stringhash__I7c()
  713. {
  714. new
  715. h0 = HASHi:fnv1a<hello>,
  716. h1 = _I@a(H,e,l,l,o);
  717. ASSERT_EQ(h0, h1);
  718. }
  719. TEST__ y_stringhash__H8c()
  720. {
  721. new
  722. h0 = HASH(fnv1a,h,e,l,l,o),
  723. h1 = _H@a<hello>;
  724. ASSERT_EQ(h0, h1);
  725. }
  726. TEST__ y_stringhash__I8c()
  727. {
  728. new
  729. h0 = HASHi(fnv1a,h,e,l,l,o),
  730. h1 = _I@a<HELLO>;
  731. ASSERT_EQ(h0, h1);
  732. }
  733. TEST__ y_stringhash__H3b()
  734. {
  735. new
  736. h0 = HASH:bernstein<hello>,
  737. h1 = HASH:bernstein<there>;
  738. ASSERT_NE(h0, h1);
  739. }
  740. TEST__ y_stringhash__I3b()
  741. {
  742. new
  743. h0 = HASHi:bernstein<hello>,
  744. h1 = HASHi:bernstein<HelLo>;
  745. ASSERT_EQ(h0, h1);
  746. }
  747. TEST__ y_stringhash__H4b()
  748. {
  749. new
  750. h0 = HASH(bernstein,h,e,l,l,o),
  751. h1 = HASH(bernstein,t,h,e,r,e);
  752. ASSERT_NE(h0, h1);
  753. }
  754. TEST__ y_stringhash__I4b()
  755. {
  756. new
  757. h0 = HASHi(bernstein,h,e,l,l,o),
  758. h1 = HASHi(bernstein,H,E,L,L,O);
  759. ASSERT_EQ(h0, h1);
  760. }
  761. TEST__ y_stringhash__H5b()
  762. {
  763. new
  764. h0 = HASH:fnv1<hello>,
  765. h1 = HASH:fnv1<there>;
  766. ASSERT_NE(h0, h1);
  767. }
  768. TEST__ y_stringhash__I5b()
  769. {
  770. new
  771. h0 = HASHi:fnv1<hello>,
  772. h1 = HASHi:fnv1<HelLo>;
  773. ASSERT_EQ(h0, h1);
  774. }
  775. TEST__ y_stringhash__H6b()
  776. {
  777. new
  778. h0 = HASH(fnv1,h,e,l,l,o),
  779. h1 = HASH(fnv1,t,h,e,r,e);
  780. ASSERT_NE(h0, h1);
  781. }
  782. TEST__ y_stringhash__I6b()
  783. {
  784. new
  785. h0 = HASHi(fnv1,h,e,l,l,o),
  786. h1 = HASHi(fnv1,H,E,L,L,O);
  787. ASSERT_EQ(h0, h1);
  788. }
  789. TEST__ y_stringhash__H7b()
  790. {
  791. new
  792. h0 = HASH:fnv1a<hello>,
  793. h1 = HASH:fnv1a<there>;
  794. ASSERT_NE(h0, h1);
  795. }
  796. TEST__ y_stringhash__I7b()
  797. {
  798. new
  799. h0 = HASHi:fnv1a<hello>,
  800. h1 = HASHi:fnv1a<HelLo>;
  801. ASSERT_EQ(h0, h1);
  802. }
  803. TEST__ y_stringhash__H8b()
  804. {
  805. new
  806. h0 = HASH(fnv1a,h,e,l,l,o),
  807. h1 = HASH(fnv1a,t,h,e,r,e);
  808. ASSERT_NE(h0, h1);
  809. }
  810. TEST__ y_stringhash__I8b()
  811. {
  812. new
  813. h0 = HASHi(fnv1a,h,e,l,l,o),
  814. h1 = HASHi(fnv1a,H,E,L,L,O);
  815. ASSERT_EQ(h0, h1);
  816. }