packages feed

hashabler-0.1.0.0: tests/Vectors/FNV.hs

module Vectors.FNV (
      fnvIn
    , fnv1a32Out
    , fnv1a64Out
    ) where

-- Official test vectors from the FNV spec here:
--   http://www.isthe.com/chongo/src/fnv/test_fnv.c
-- Omiting the null-terminated string tests:
--
-- DO NOT MODIFY
--

import Data.Word(Word32,Word64)

r :: Int -> String -> String
r n = concat . replicate n

test :: String -> String
test = id

test0 :: String -> String
test0 s = s++"\NUL"

fnvIn :: [String]
fnvIn = [
      test(""),
      test("a"),
      test("b"),
      test("c"),
      test("d"),
      test("e"),
      test("f"),
      test("fo"),
      test("foo"),
      test("foob"),
      test("fooba"),
      test("foobar"),
      test0(""),
      test0("a"),
      test0("b"),
      test0("c"),
      test0("d"),
      test0("e"),
      test0("f"),
      test0("fo"),
      test0("foo"),
      test0("foob"),
      test0("fooba"),
      test0("foobar"),
      test("ch"),
      test("cho"),
      test("chon"),
      test("chong"),
      test("chongo"),
      test("chongo "),
      test("chongo w"),
      test("chongo wa"),
      test("chongo was"),
      test("chongo was "),
      test("chongo was h"),
      test("chongo was he"),
      test("chongo was her"),
      test("chongo was here"),
      test("chongo was here!"),
      test("chongo was here!\n"),
      test0("ch"),
      test0("cho"),
      test0("chon"),
      test0("chong"),
      test0("chongo"),
      test0("chongo "),
      test0("chongo w"),
      test0("chongo wa"),
      test0("chongo was"),
      test0("chongo was "),
      test0("chongo was h"),
      test0("chongo was he"),
      test0("chongo was her"),
      test0("chongo was here"),
      test0("chongo was here!"),
      test0("chongo was here!\n"),
      test("cu"),
      test("cur"),
      test("curd"),
      test("curds"),
      test("curds "),
      test("curds a"),
      test("curds an"),
      test("curds and"),
      test("curds and "),
      test("curds and w"),
      test("curds and wh"),
      test("curds and whe"),
      test("curds and whey"),
      test("curds and whey\n"),
      test0("cu"),
      test0("cur"),
      test0("curd"),
      test0("curds"),
      test0("curds "),
      test0("curds a"),
      test0("curds an"),
      test0("curds and"),
      test0("curds and "),
      test0("curds and w"),
      test0("curds and wh"),
      test0("curds and whe"),
      test0("curds and whey"),
      test0("curds and whey\n"),
      test("hi"), test0("hi"),
      test("hello"), test0("hello"),
      test("\xff\x00\x00\x01"), test("\x01\x00\x00\xff"),
      test("\xff\x00\x00\x02"), test("\x02\x00\x00\xff"),
      test("\xff\x00\x00\x03"), test("\x03\x00\x00\xff"),
      test("\xff\x00\x00\x04"), test("\x04\x00\x00\xff"),
      test("\x40\x51\x4e\x44"), test("\x44\x4e\x51\x40"),
      test("\x40\x51\x4e\x4a"), test("\x4a\x4e\x51\x40"),
      test("\x40\x51\x4e\x54"), test("\x54\x4e\x51\x40"),
      test("127.0.0.1"), test0("127.0.0.1"),
      test("127.0.0.2"), test0("127.0.0.2"),
      test("127.0.0.3"), test0("127.0.0.3"),
      test("64.81.78.68"), test0("64.81.78.68"),
      test("64.81.78.74"), test0("64.81.78.74"),
      test("64.81.78.84"), test0("64.81.78.84"),
      test("feedface"), test0("feedface"),
      test("feedfacedaffdeed"), test0("feedfacedaffdeed"),
      test("feedfacedeadbeef"), test0("feedfacedeadbeef"),
      test("line 1\nline 2\nline 3"),
      test("chongo <Landon Curt Noll> /\\../\\"),
      test0("chongo <Landon Curt Noll> /\\../\\"),
      test("chongo (Landon Curt Noll) /\\../\\"),
      test0("chongo (Landon Curt Noll) /\\../\\"),
      test("http://antwrp.gsfc.nasa.gov/apod/astropix.html"),
      test("http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash"),
      test("http://epod.usra.edu/"),
      test("http://exoplanet.eu/"),
      test("http://hvo.wr.usgs.gov/cam3/"),
      test("http://hvo.wr.usgs.gov/cams/HMcam/"),
      test("http://hvo.wr.usgs.gov/kilauea/update/deformation.html"),
      test("http://hvo.wr.usgs.gov/kilauea/update/images.html"),
      test("http://hvo.wr.usgs.gov/kilauea/update/maps.html"),
      test("http://hvo.wr.usgs.gov/volcanowatch/current_issue.html"),
      test("http://neo.jpl.nasa.gov/risk/"),
      test("http://norvig.com/21-days.html"),
      test("http://primes.utm.edu/curios/home.php"),
      test("http://slashdot.org/"),
      test("http://tux.wr.usgs.gov/Maps/155.25-19.5.html"),
      test("http://volcano.wr.usgs.gov/kilaueastatus.php"),
      test("http://www.avo.alaska.edu/activity/Redoubt.php"),
      test("http://www.dilbert.com/fast/"),
      test("http://www.fourmilab.ch/gravitation/orbits/"),
      test("http://www.fpoa.net/"),
      test("http://www.ioccc.org/index.html"),
      test("http://www.isthe.com/cgi-bin/number.cgi"),
      test("http://www.isthe.com/chongo/bio.html"),
      test("http://www.isthe.com/chongo/index.html"),
      test("http://www.isthe.com/chongo/src/calc/lucas-calc"),
      test("http://www.isthe.com/chongo/tech/astro/venus2004.html"),
      test("http://www.isthe.com/chongo/tech/astro/vita.html"),
      test("http://www.isthe.com/chongo/tech/comp/c/expert.html"),
      test("http://www.isthe.com/chongo/tech/comp/calc/index.html"),
      test("http://www.isthe.com/chongo/tech/comp/fnv/index.html"),
      test("http://www.isthe.com/chongo/tech/math/number/howhigh.html"),
      test("http://www.isthe.com/chongo/tech/math/number/number.html"),
      test("http://www.isthe.com/chongo/tech/math/prime/mersenne.html"),
      test("http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest"),
      test("http://www.lavarnd.org/cgi-bin/corpspeak.cgi"),
      test("http://www.lavarnd.org/cgi-bin/haiku.cgi"),
      test("http://www.lavarnd.org/cgi-bin/rand-none.cgi"),
      test("http://www.lavarnd.org/cgi-bin/randdist.cgi"),
      test("http://www.lavarnd.org/index.html"),
      test("http://www.lavarnd.org/what/nist-test.html"),
      test("http://www.macosxhints.com/"),
      test("http://www.mellis.com/"),
      test("http://www.nature.nps.gov/air/webcams/parks/havoso2alert/havoalert.cfm"),
      test("http://www.nature.nps.gov/air/webcams/parks/havoso2alert/timelines_24.cfm"),
      test("http://www.paulnoll.com/"),
      test("http://www.pepysdiary.com/"),
      test("http://www.sciencenews.org/index/home/activity/view"),
      test("http://www.skyandtelescope.com/"),
      test("http://www.sput.nl/~rob/sirius.html"),
      test("http://www.systemexperts.com/"),
      test("http://www.tq-international.com/phpBB3/index.php"),
      test("http://www.travelquesttours.com/index.htm"),
      test("http://www.wunderground.com/global/stations/89606.html"),
      test(r 10 ("21701")),
      test(r 10 ("M21701")),
      test(r 10 ("2^21701-1")),
      test(r 10 ("\x54\xc5")),
      test(r 10 ("\xc5\x54")),
      test(r 10 ("23209")),
      test(r 10 ("M23209")),
      test(r 10 ("2^23209-1")),
      test(r 10 ("\x5a\xa9")),
      test(r 10 ("\xa9\x5a")),
      test(r 10 ("391581216093")),
      test(r 10 ("391581*2^216093-1")),
      test(r 10 ("\x05\xf9\x9d\x03\x4c\x81")),
      test(r 10 ("FEDCBA9876543210")),
      test(r 10 ("\xfe\xdc\xba\x98\x76\x54\x32\x10")),
      test(r 10 ("EFCDAB8967452301")),
      test(r 10 ("\xef\xcd\xab\x89\x67\x45\x23\x01")),
      test(r 10 ("0123456789ABCDEF")),
      test(r 10 ("\x01\x23\x45\x67\x89\xab\xcd\xef")),
      test(r 10 ("1032547698BADCFE")),
      test(r 10 ("\x10\x32\x54\x76\x98\xba\xdc\xfe")),
      test(r 500 ("\x00")),
      test(r 500 ("\x07")),
      test(r 500 ("~")),
      test(r 500 ("\x7f"))
    ]

-- FNV-1a 32 bit test vectors
fnv1a32Out :: [ Word32 ]
fnv1a32Out = [
    0x811c9dc5,
    0xe40c292c,
    0xe70c2de5,
    0xe60c2c52,
    0xe10c2473,
    0xe00c22e0,
    0xe30c2799,
    0x6222e842,
    0xa9f37ed7,
    0x3f5076ef,
    0x39aaa18a,
    0xbf9cf968,
    0x050c5d1f,
    0x2b24d044,
    0x9d2c3f7f,
    0x7729c516,
    0xb91d6109,
    0x931ae6a0,
    0x052255db,
    0xbef39fe6,
    0x6150ac75,
    0x9aab3a3d,
    0x519c4c3e,
    0x0c1c9eb8,
    0x5f299f4e,
    0xef8580f3,
    0xac297727,
    0x4546b9c0,
    0xbd564e7d,
    0x6bdd5c67,
    0xdd77ed30,
    0xf4ca9683,
    0x4aeb9bd0,
    0xe0e67ad0,
    0xc2d32fa8,
    0x7f743fb7,
    0x6900631f,
    0xc59c990e,
    0x448524fd,
    0xd49930d5,
    0x1c85c7ca,
    0x0229fe89,
    0x2c469265,
    0xce566940,
    0x8bdd8ec7,
    0x34787625,
    0xd3ca6290,
    0xddeaf039,
    0xc0e64870,
    0xdad35570,
    0x5a740578,
    0x5b004d15,
    0x6a9c09cd,
    0x2384f10a,
    0xda993a47,
    0x8227df4f,
    0x4c298165,
    0xfc563735,
    0x8cb91483,
    0x775bf5d0,
    0xd5c428d0,
    0x34cc0ea3,
    0xea3b4cb7,
    0x8e59f029,
    0x2094de2b,
    0xa65a0ad4,
    0x9bbee5f4,
    0xbe836343,
    0x22d5344e,
    0x19a1470c,
    0x4a56b1ff,
    0x70b8e86f,
    0x0a5b4a39,
    0xb5c3f670,
    0x53cc3f70,
    0xc03b0a99,
    0x7259c415,
    0x4095108b,
    0x7559bdb1,
    0xb3bf0bbc,
    0x2183ff1c,
    0x2bd54279,
    0x23a156ca,
    0x64e2d7e4,
    0x683af69a,
    0xaed2346e,
    0x4f9f2cab,
    0x02935131,
    0xc48fb86d,
    0x2269f369,
    0xc18fb3b4,
    0x50ef1236,
    0xc28fb547,
    0x96c3bf47,
    0xbf8fb08e,
    0xf3e4d49c,
    0x32179058,
    0x280bfee6,
    0x30178d32,
    0x21addaf8,
    0x4217a988,
    0x772633d6,
    0x08a3d11e,
    0xb7e2323a,
    0x07a3cf8b,
    0x91dfb7d1,
    0x06a3cdf8,
    0x6bdd3d68,
    0x1d5636a7,
    0xd5b808e5,
    0x1353e852,
    0xbf16b916,
    0xa55b89ed,
    0x3c1a2017,
    0x0588b13c,
    0xf22f0174,
    0xe83641e1,
    0x6e69b533,
    0xf1760448,
    0x64c8bd58,
    0x97b4ea23,
    0x9a4e92e6,
    0xcfb14012,
    0xf01b2511,
    0x0bbb59c3,
    0xce524afa,
    0xdd16ef45,
    0x60648bb3,
    0x7fa4bcfc,
    0x5053ae17,
    0xc9302890,
    0x956ded32,
    0x9136db84,
    0xdf9d3323,
    0x32bb6cd0,
    0xc8f8385b,
    0xeb08bfba,
    0x62cc8e3d,
    0xc3e20f5c,
    0x39e97f17,
    0x7837b203,
    0x319e877b,
    0xd3e63f89,
    0x29b50b38,
    0x5ed678b8,
    0xb0d5b793,
    0x52450be5,
    0xfa72d767,
    0x95066709,
    0x7f52e123,
    0x76966481,
    0x063258b0,
    0x2ded6e8a,
    0xb07d7c52,
    0xd0c71b71,
    0xf684f1bd,
    0x868ecfa8,
    0xf794f684,
    0xd19701c3,
    0x346e171e,
    0x91f8f676,
    0x0bf58848,
    0x6317b6d1,
    0xafad4c54,
    0x0f25681e,
    0x91b18d49,
    0x7d61c12e,
    0x5147d25c,
    0x9a8b6805,
    0x4cd2a447,
    0x1e549b14,
    0x2fe1b574,
    0xcf0cd31e,
    0x6c471669,
    0x0e5eef1e,
    0x2bed3602,
    0xb26249e0,
    0x2c9b86a4,
    0xe415e2bb,
    0x18a98d1d,
    0xb7df8b7b,
    0x241e9075,
    0x063f70dd,
    0x0295aed9,
    0x56a7f781,
    0x253bc645,
    0x46610921,
    0x7c1577f9,
    0x512b2851,
    0x76823999,
    0xc0586935,
    0xf3415c85,
    0x0ae4ff65,
    0x58b79725,
    0xdea43aa5,
    0x2bb3be35,
    0xea777a45,
    0x8f21c305,
    0x5c9d0865,
    0xfa823dd5,
    0x21a27271,
    0x83c5c6d5,
    0x813b0881
    ]

fnv1a64Out :: [Word64]
fnv1a64Out = [
     0xcbf29ce484222325,
     0xaf63dc4c8601ec8c,
     0xaf63df4c8601f1a5,
     0xaf63de4c8601eff2,
     0xaf63d94c8601e773,
     0xaf63d84c8601e5c0,
     0xaf63db4c8601ead9,
     0x08985907b541d342,
     0xdcb27518fed9d577,
     0xdd120e790c2512af,
     0xcac165afa2fef40a,
     0x85944171f73967e8,
     0xaf63bd4c8601b7df,
     0x089be207b544f1e4,
     0x08a61407b54d9b5f,
     0x08a2ae07b54ab836,
     0x0891b007b53c4869,
     0x088e4a07b5396540,
     0x08987c07b5420ebb,
     0xdcb28a18fed9f926,
     0xdd1270790c25b935,
     0xcac146afa2febf5d,
     0x8593d371f738acfe,
     0x34531ca7168b8f38,
     0x08a25607b54a22ae,
     0xf5faf0190cf90df3,
     0xf27397910b3221c7,
     0x2c8c2b76062f22e0,
     0xe150688c8217b8fd,
     0xf35a83c10e4f1f87,
     0xd1edd10b507344d0,
     0x2a5ee739b3ddb8c3,
     0xdcfb970ca1c0d310,
     0x4054da76daa6da90,
     0xf70a2ff589861368,
     0x4c628b38aed25f17,
     0x9dd1f6510f78189f,
     0xa3de85bd491270ce,
     0x858e2fa32a55e61d,
     0x46810940eff5f915,
     0xf5fadd190cf8edaa,
     0xf273ed910b32b3e9,
     0x2c8c5276062f6525,
     0xe150b98c821842a0,
     0xf35aa3c10e4f55e7,
     0xd1ed680b50729265,
     0x2a5f0639b3dded70,
     0xdcfbaa0ca1c0f359,
     0x4054ba76daa6a430,
     0xf709c7f5898562b0,
     0x4c62e638aed2f9b8,
     0x9dd1a8510f779415,
     0xa3de2abd4911d62d,
     0x858e0ea32a55ae0a,
     0x46810f40eff60347,
     0xc33bce57bef63eaf,
     0x08a24307b54a0265,
     0xf5b9fd190cc18d15,
     0x4c968290ace35703,
     0x07174bd5c64d9350,
     0x5a294c3ff5d18750,
     0x05b3c1aeb308b843,
     0xb92a48da37d0f477,
     0x73cdddccd80ebc49,
     0xd58c4c13210a266b,
     0xe78b6081243ec194,
     0xb096f77096a39f34,
     0xb425c54ff807b6a3,
     0x23e520e2751bb46e,
     0x1a0b44ccfe1385ec,
     0xf5ba4b190cc2119f,
     0x4c962690ace2baaf,
     0x0716ded5c64cda19,
     0x5a292c3ff5d150f0,
     0x05b3e0aeb308ecf0,
     0xb92a5eda37d119d9,
     0x73ce41ccd80f6635,
     0xd58c2c132109f00b,
     0xe78baf81243f47d1,
     0xb0968f7096a2ee7c,
     0xb425a84ff807855c,
     0x23e4e9e2751b56f9,
     0x1a0b4eccfe1396ea,
     0x54abd453bb2c9004,
     0x08ba5f07b55ec3da,
     0x337354193006cb6e,
     0xa430d84680aabd0b,
     0xa9bc8acca21f39b1,
     0x6961196491cc682d,
     0xad2bb1774799dfe9,
     0x6961166491cc6314,
     0x8d1bb3904a3b1236,
     0x6961176491cc64c7,
     0xed205d87f40434c7,
     0x6961146491cc5fae,
     0xcd3baf5e44f8ad9c,
     0xe3b36596127cd6d8,
     0xf77f1072c8e8a646,
     0xe3b36396127cd372,
     0x6067dce9932ad458,
     0xe3b37596127cf208,
     0x4b7b10fa9fe83936,
     0xaabafe7104d914be,
     0xf4d3180b3cde3eda,
     0xaabafd7104d9130b,
     0xf4cfb20b3cdb5bb1,
     0xaabafc7104d91158,
     0xf4cc4c0b3cd87888,
     0xe729bac5d2a8d3a7,
     0x74bc0524f4dfa4c5,
     0xe72630c5d2a5b352,
     0x6b983224ef8fb456,
     0xe73042c5d2ae266d,
     0x8527e324fdeb4b37,
     0x0a83c86fee952abc,
     0x7318523267779d74,
     0x3e66d3d56b8caca1,
     0x956694a5c0095593,
     0xcac54572bb1a6fc8,
     0xa7a4c9f3edebf0d8,
     0x7829851fac17b143,
     0x2c8f4c9af81bcf06,
     0xd34e31539740c732,
     0x3605a2ac253d2db1,
     0x08c11b8346f4a3c3,
     0x6be396289ce8a6da,
     0xd9b957fb7fe794c5,
     0x05be33da04560a93,
     0x0957f1577ba9747c,
     0xda2cc3acc24fba57,
     0x74136f185b29e7f0,
     0xb2f2b4590edb93b2,
     0xb3608fce8b86ae04,
     0x4a3a865079359063,
     0x5b3a7ef496880a50,
     0x48fae3163854c23b,
     0x07aaa640476e0b9a,
     0x2f653656383a687d,
     0xa1031f8e7599d79c,
     0xa31908178ff92477,
     0x097edf3c14c3fb83,
     0xb51ca83feaa0971b,
     0xdd3c0d96d784f2e9,
     0x86cd26a9ea767d78,
     0xe6b215ff54a30c18,
     0xec5b06a1c5531093,
     0x45665a929f9ec5e5,
     0x8c7609b4a9f10907,
     0x89aac3a491f0d729,
     0x32ce6b26e0f4a403,
     0x614ab44e02b53e01,
     0xfa6472eb6eef3290,
     0x9e5d75eb1948eb6a,
     0xb6d12ad4a8671852,
     0x88826f56eba07af1,
     0x44535bf2645bc0fd,
     0x169388ffc21e3728,
     0xf68aac9e396d8224,
     0x8e87d7e7472b3883,
     0x295c26caa8b423de,
     0x322c814292e72176,
     0x8a06550eb8af7268,
     0xef86d60e661bcf71,
     0x9e5426c87f30ee54,
     0xf1ea8aa826fd047e,
     0x0babaf9a642cb769,
     0x4b3341d4068d012e,
     0xd15605cbc30a335c,
     0x5b21060aed8412e5,
     0x45e2cda1ce6f4227,
     0x50ae3745033ad7d4,
     0xaa4588ced46bf414,
     0xc1b0056c4a95467e,
     0x56576a71de8b4089,
     0xbf20965fa6dc927e,
     0x569f8383c2040882,
     0xe1e772fba08feca0,
     0x4ced94af97138ac4,
     0xc4112ffb337a82fb,
     0xd64a4fd41de38b7d,
     0x4cfc32329edebcbb,
     0x0803564445050395,
     0xaa1574ecf4642ffd,
     0x694bc4e54cc315f9,
     0xa3d7cb273b011721,
     0x577c2f8b6115bfa5,
     0xb7ec8c1a769fb4c1,
     0x5d5cfce63359ab19,
     0x33b96c3cd65b5f71,
     0xd845097780602bb9,
     0x84d47645d02da3d5,
     0x83544f33b58773a5,
     0x9175cbb2160836c5,
     0xc71b3bc175e72bc5,
     0x636806ac222ec985,
     0xb6ef0e6950f52ed5,
     0xead3d8a0f3dfdaa5,
     0x922908fe9a861ba5,
     0x6d4821de275fd5c5,
     0x1fe3fce62bd816b5,
     0xc23e9fccd6f70591,
     0xc1af12bdfe16b5b5,
     0x39e9f18f2f85e221
    ]