summary refs log tree commit diff stats
path: root/test/defaultbucket.cratera
blob: 573e197e5070a843e2dce558e3c81a7dbde39f1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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")