summary refs log tree commit diff stats
path: root/test/defaultbucket.cratera
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2024-06-09 13:02:25 -0300
committerSoniEx2 <endermoneymod@gmail.com>2024-06-09 13:02:25 -0300
commitca6e4d141484331a25cfa67cf370000b74d7725f (patch)
treec157a393a202044f08b02a35c5e055f3f1ba6243 /test/defaultbucket.cratera
parent2751039739e5357beb8e858a25e21e2bc0344fe8 (diff)
Add hashmap implementation
Diffstat (limited to 'test/defaultbucket.cratera')
-rw-r--r--test/defaultbucket.cratera22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/defaultbucket.cratera b/test/defaultbucket.cratera
new file mode 100644
index 0000000..fd7281e
--- /dev/null
+++ b/test/defaultbucket.cratera
@@ -0,0 +1,22 @@
+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)