-
Notifications
You must be signed in to change notification settings - Fork 0
/
string_test.v
64 lines (58 loc) · 2.04 KB
/
string_test.v
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
55
56
57
58
59
60
61
62
63
64
module vredis
fn test_string() ! {
mut redis := new_client()!
defer {
redis.close() or {}
}
redis.debug = true
assert redis.flushall()!
multi_key := 'api
domain'
multi_str := 'api."
vlang.
io'
assert redis.set(multi_key, multi_str)!
assert redis.get(multi_key)! == multi_str
assert redis.ping()! == true
assert redis.@type('website')! == 'none'
assert redis.del(multi_key)!
assert redis.set('website', 'www')!
assert redis.randomkey()! == 'website'
assert redis.@type('website')! == 'string'
assert redis.ttl('website')! == -1
assert redis.pttl('website')! == -1
assert redis.get('website')! == 'www'
assert redis.get('xxxx')! == '(nil)'
assert redis.incr('vredis_counter')! == 1
assert redis.incrby('vredis_counter', 2)! == 3
assert redis.decrby('vredis_counter', 2)! == 1
assert redis.decr('vredis_counter')! == 0
assert redis.incrbyfloat('vredis_counter', 1.1)! == 1.1
assert redis.incrbyfloat('vredis_counter', 2.23)! == 3.33
assert redis.incrbyfloat('vredis_counter', -3.33)! == 0
assert redis.append('website', '.vlang.io')! == 12
assert redis.strlen('website')! == 12
assert redis.get('website')! == 'www.vlang.io'
assert redis.getrange('website', 0, 2)! == 'www'
assert redis.getset('exists', 'exists')! == '(nil)'
assert redis.getset('exists', 'exists')! == 'exists'
assert redis.setrange('exists', 0, 'mo')! == 6
assert redis.get('exists')! == 'moists'
assert redis.mget('exists')!.bytestr() == "{'exists': 'moists'}"
assert redis.keys('*')!.len == 3
assert redis.rename('exists', '_exists')!
assert redis.exists('exists')! == false
assert redis.exists('_exists')!
assert redis.del('exists')! == false
assert redis.expire('_exists', 1)!
assert redis.ttl('_exists')! == 1
assert redis.pttl('_exists')! <= 1000
assert redis.ttl('website')! == -1
assert redis.pttl('website')! == -1
assert redis.renamenx('_exists', 'website')! == false
assert redis.renamenx('_exists', 'exists')!
assert redis.setbit('bits', 0, 1)!
assert redis.getbit('bits', 0) == 1
assert redis.getbit('bits', 1) == 0
println(redis.scan(count: 1)!)
}