tests.inc 17 KB

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