summary refs log blame commit diff stats
path: root/test/defaultbucket.cratera
blob: 573e197e5070a843e2dce558e3c81a7dbde39f1f (plain) (tree)





















                                              
                                 
local bucketlib = require "cratera.lib.bucket"

local Bucket = bucketlib.Bucket
local DefaultBucket = bucketlib.DefaultBucket

local function hash_n(n)
    local bucket = DefaultBucket()
    bucket:[Bucket].put_number(n)
    return bucket:[Bucket].finish()
end

local function hash_s(n)
    local bucket = DefaultBucket()
    bucket:[Bucket].put_string(n)
    return bucket:[Bucket].finish()
end

assert(hash_n(1) == 1)
assert(hash_n(2) == 2)
assert(hash_n(-1) == 1)
assert(hash_s("") == 0)
assert(hash_s("h") == string.byte("h")+31)
print("defaultbucket tests pass")