-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.lua
54 lines (48 loc) · 1.47 KB
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
local bitpack = require "bitpack"
local bp = bitpack.new()
bitpack.new(2400 * 2400)
bitpack.new("asdf")
-- bitpack.new(-199)
print("to_bytes:", bp:to_bytes())
print("size:", bp:size())
print("alloc_bytes:", bp:alloc_bytes())
print("on:", bp:on(10))
print("get:", bp:get(10))
print("off:", bp:off(1))
print("get:", bp:get(10))
print("to_bytes:", bp:to_bytes())
print("off:", bp:off(10))
print("get:", bp:get(10))
print("to_bytes:", bp:to_bytes())
print("get:", bp:get(100))
print("on:", bp:on(100))
print("off:", bp:off(100))
print("size:", bp:size())
print("alloc_bytes:", bp:alloc_bytes())
print("to_bytes:", bp:to_bytes())
print("on:", bp:on(80000))
print("size:", bp:size())
print("alloc_bytes:", bp:alloc_bytes())
print("to_bytes:", bp:to_bytes())
print('=======================')
local bp1 = bitpack.new(4)
print("size:", bp1:size())
print("alloc_bytes:", bp1:alloc_bytes())
print("to_bytes:", bp1:to_bytes())
print("set_bytes:", bp1:set_bytes(0, "asdf"))
print("size:", bp1:size())
print("alloc_bytes:", bp1:alloc_bytes())
local s = bp1:to_bytes()
print("to_bytes:", s, #s, string.byte(s, 1, #s))
s = bp1:get_bytes(0, 4)
print("get_bytes:", s, #s)
print("get_bytes:", bp1:get_bytes(32, 4))
print("get_bytes:", bp1:get_bytes(0, 5))
s = bp1:get_bytes(8, 2)
print("get_bytes:", s, #s)
print("size:", bp1:size())
print("to_bytes:", bp1:to_bytes())
print("append_bytes:", bp1:append_bytes("xyz"))
print("size:", bp1:size())
print("alloc_bytes:", bp1:alloc_bytes())
print("to_bytes:", bp1:to_bytes())