extern crate core; extern crate wyhash; use core::hash::Hasher; use wyhash::{wyhash, WyHash}; #[test] fn wyhash_test() { let mut data = [0; 256]; for i in 0..data.len() { data[i] = i as u8; assert_eq!(ORIGINAL_HASHES[i], wyhash(&data[..i], i as u64)); } } #[test] fn core_hasher() { let mut data = [0; 256]; for i in 0..data.len() { data[i] = i as u8; let mut hasher = WyHash::with_seed(i as u64); hasher.write(&data[..i]); assert_eq!(ORIGINAL_HASHES[i], hasher.finish()); } } // Results from the cannonical C implementation #[allow(clippy::unreadable_literal)] const ORIGINAL_HASHES: [u64; 256] = [ 0xf961f936e29c9345, 0x83fcbe65126830a3, 0xcaed38c4bfba7448, 0xb0f941520b1ad95d, 0x22fc0d05b5655593, 0xaf963b6ca51ab9dd, 0x8ae9d75ba5a841b8, 0xfd1d46ecd66b6c3b, 0x276e8d0315af0b78, 0x8712dbf1d543727b, 0x9b39e6894e1f146c, 0xc43124ed65b41cb5, 0xd3ddfd4520189f1c, 0xe7a1d44fc4d6d1f, 0x4db5af6fa882b123, 0xe72bf394ca9aad73, 0x9510769567e2b9f5, 0xe4c8addf5e52d332, 0x7bf687b31360f0d0, 0xdb8ef4223e1e1b60, 0x43b5b515c3fb98be, 0x513ecead364b50c1, 0x51a6f8a448b6d3b5, 0xad62961a82d455ad, 0xbcbe2c377a034906, 0x89fbf3a60852bc2d, 0xf26147c1df25be1, 0x287f458f65e918b3, 0x5055a2d6fe3503e3, 0x872e8ec2f5234fe3, 0xf02fc2225cccac35, 0x855f219b5e0f78bf, 0x39e624e60cf044f5, 0x954b951660265062, 0x10717cafd43c8016, 0xaac9f9536ade0cdf, 0x85826a82847dfb60, 0x1ec660576eee25a0, 0x7e3d61e547921405, 0x48d0278d0885804, 0xf9a12dcc5526d1ee, 0x7f535ae5fb44c366, 0x91436439a22f53ae, 0x502163656e8fa341, 0x1b456138914ce2c8, 0x31fb06ca008488f2, 0x224190a27cfc3ea2, 0xd042cea2c304d169, 0x82f97b9295a4669d, 0xb911cc536d51aee3, 0xf8262e139dd87df, 0x46a7bfeb53c93a37, 0x5b0a349881c68bbe, 0x7346d8f965ce7a50, 0x6aa0ce0b81b802d3, 0xc1183d47ceb38941, 0x3c39115f8dcb426b, 0x920e3b4c7b45a7cf, 0x9604099240820192, 0x8ef3bd1d39cdd917, 0x820a7dc133ba218d, 0x65e4f4965178d3b3, 0xdeb525c6a117485f, 0x20f7c7d18e52a7ad, 0x56d5ee41b0b04b2c, 0x3ac5ed752a1e2b1b, 0x32cea51b8e513aeb, 0x6c283bcf574d8f78, 0x8d4eba6afdee9f63, 0xb09f641d6f577975, 0x8dd7f0d3709abba7, 0xad33a90846d659cf, 0xe25fca49c58addc6, 0x2440f6a61d350ed5, 0x6b84724e57a33f16, 0xb565dc3d397d2b99, 0x614e76954d9db55c, 0x5ba3e16e2850e8e9, 0x3d99a751ecfbb12a, 0xbcadde62cc4170e6, 0x14b43b747a10e7b1, 0x965716de200e679f, 0xcfc034e9d99273fc, 0xe6e24212240e06c8, 0x7a3a43aeb5d5832, 0x53a46badd5b1c2e4, 0xefc8f1ca072cb287, 0xa219af4c6017d8df, 0xfcf81d7e062b5b4d, 0x99f7c43b6c8d15df, 0xfa9d43de6e2dcf8d, 0x49440250024465e8, 0xc93dc0341dfe68c6, 0x7371117edfaa3cef, 0xda507c5cc7c7861f, 0x8dc7b9c7de61dfa0, 0x3790aac1a0b4dc9e, 0x69276f1b576327, 0xdb28a344a9a89dc2, 0xd37946ceed53eaff, 0x20b2de3702e39858, 0xec040b298f205b6b, 0xe9cccd97a8752500, 0x5a5bdffe4bc258c9, 0xa5e6a7de6c699302, 0xaa0ccf8a499d2fff, 0x3f20fad08660f5fb, 0xd43a1e26a81ac863, 0x1071487504fb9242, 0xc49d54d1e6eaa5b9, 0x16a16bca2b1af019, 0xe49a7a06061ef52e, 0x50bf68c261a59d0c, 0x3f8c3765bf1319b5, 0x446d718cd877c877, 0x22498a0894312207, 0x6b3704625c841542, 0xf54635bee4b04e29, 0x12a1bbadbf348c7, 0x31634471a17a8e1f, 0xdb6a4520c46bcd2e, 0x147ac2e4e291524b, 0xb0c69df46e205428, 0x3ec0c0555be5b93c, 0x7e0bfc7a00dc8338, 0xf31c5ceea850958b, 0xb35011374d62ee22, 0x1768495be7e5f9c4, 0xec1d87cf207b5500, 0x7868b46f37dde010, 0xc564b8d538d74383, 0xebe336d3b4b30623, 0xf08863d276be2ab7, 0xb1d9a06182c82353, 0x74a76e581a2f789c, 0xbd3bee630fabadd3, 0xa7de866a4d63af1d, 0x454b176b32b245fa, 0x224606473973b6b, 0xb5cfaa3bc3b8dfec, 0xd5f72aa9cdabbd8e, 0xa7a45228925ba20d, 0x959274cf8d05674a, 0x2ea87b477fa5c092, 0x710aa3c765472c8f, 0xd0a6c151ab0da3b1, 0x323fa4b54bb6bc98, 0xd60634f023573652, 0x3ce86bcb32af9882, 0x1d875561fb90c2b8, 0x368b85acc5d3a430, 0xfada816c75e6b3db, 0x7772421111391ecb, 0x6750845bb9686a33, 0xe6e949cd5af342c0, 0x49a2d3cb690c2e43, 0x8d779ab8a0a1639f, 0xde4a98c22bdaa947, 0xc9ab33025391ea81, 0xeb3a93d56aa8dd75, 0x65e94f5e3d28f9da, 0x3f9f4ffc3db07d1a, 0x485f6aa5e1d0753, 0xb70c36d152b9c187, 0x2ac871e33f83fe6c, 0x1da741e30aa10174, 0xbbd508ad7d490b06, 0x24deb16289cc3964, 0xb6f1107e77327972, 0x6615db4385b8fef0, 0xd2e822bf0fa64e63, 0x53ed6306086fb744, 0xcb6b0aa0e1ee2460, 0x3bfa4b3350270ed6, 0x59effd2041fd4d08, 0x43fcc61c02ca632e, 0xaf7553a0965cfd0a, 0xfab7185981e27a2, 0xc3fc759bc9680c1a, 0x32483ee8f8797b42, 0x4eb0f9ef1b525255, 0x9ce0ffb044ce6436, 0x63052fb9cbcb44df, 0x301c22b6072bd122, 0x68b60f1bcdbe9450, 0x1e8954848ebd28f2, 0x104cd602bbe2e67, 0xfcd846dc9107c76e, 0x57d69ef746b3de04, 0xd4837690ab53eaa8, 0x8e50ea4999bb7894, 0xccc1ea55a74693f6, 0x92b51070fa1bc088, 0x7b86c06ecff5f597, 0x4b94fd254936b1e7, 0x58fe1fc0c0628e01, 0x93d5f8896977d760, 0x761e6fad2db0b6f4, 0x8e993cc2e5cdfcf7, 0x36924dac5e282c71, 0xa22cad8a04372681, 0x4e8496a9f383addf, 0x201b621b31a992ba, 0xe01cf091118895e4, 0x26459bef7953ab3a, 0xc06fe833ea4571ee, 0x545502fdbadb8849, 0xf489ac975de5e0de, 0xc578d69c4d5ff83e, 0x146571e5cd3a0fa7, 0x5cb7a1d4c70d6b2a, 0x5298e3f6ffe15f0d, 0x3682776527687209, 0x11b19a59524fdbf2, 0xa9590279d60a8b1b, 0xaa3ea2c18819120a, 0x2766ad893c1d542d, 0xe2a47768498bd688, 0x2e1f0a701e47296d, 0x4f1463b2d4d0c9fb, 0xee608c4a03fdfa31, 0xd4d2161b72e4cb69, 0x5fc89e3bcf8e9e6f, 0x8ce8ad18a3a71064, 0x1a6e3c456becb8b, 0xe3c8a6635be383ed, 0xf38b80a7621ddcd7, 0x908a2152f9ac845e, 0x8dac52b763bf028b, 0xdf59b057044e9031, 0xd503a0d875c98990, 0x9ed2c1a50ead3fb1, 0xf2fcc1704dd1128c, 0x91eb226c91da553e, 0x21e07a2d3a8d6450, 0x25bc2bf14002d336, 0x73a524c6212ede2f, 0xc7b83f83a798fc7d, 0x33bd8f399e8b3741, 0xb2d48f0d7c33992b, 0xa8a25b6b259c39cc, 0x4aafb95636c6ff3b, 0xf685c0c56739cbf3, 0x5f885605ada76029, 0x6ed22d6c51b17caf, 0x6bfd04b4c808c0b5, 0xab358de568fcbc61, 0x97e42da2f992dca5, 0xeaeee49fc4a16045, 0xa8fef7bcce13efcc, 0xd3c5ba9c0aaa0f44, 0xd240d969c3f04b28, 0x541eebca40288dc4, 0x292768477779dc00, 0x172788219608034c, 0xd5024d6272206ba, ];