-
Notifications
You must be signed in to change notification settings - Fork 34
/
assignment_test.go
51 lines (40 loc) · 1.13 KB
/
assignment_test.go
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
package roger
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func checkAssignment(t *testing.T, assignmentObj interface{}) {
client, _ := NewRClient("localhost", 6311)
sess, _ := client.GetSession()
defer sess.Close()
err := sess.Assign("assignedVar", assignmentObj)
assert.Equal(t, err, nil)
obj, err := sess.Eval("assignedVar")
assert.Equal(t, assignmentObj, obj)
assert.Equal(t, nil, err)
}
func TestIntArrayAssignment(t *testing.T) {
checkAssignment(t, []int32{1, 2, 3, 4, 5})
}
func TestIntAssignment(t *testing.T) {
checkAssignment(t, int32(100))
}
func TestDoubleAssignment(t *testing.T) {
checkAssignment(t, float64(123.4))
}
func TestFloatArrayAssignment(t *testing.T) {
checkAssignment(t, []float64{1.1, 2.2, 3.3, 4.4, 5.5})
}
func TestStringArrayAssignment(t *testing.T) {
checkAssignment(t, []string{"test", "str"})
}
func TestByteArrayAssignment(t *testing.T) {
checkAssignment(t, []byte{'g', 'o', 'l', 'a', 'n', 'g'})
}
func TestStringAssignment(t *testing.T) {
checkAssignment(t, "testing")
}
func TestLargeStringAssignment(t *testing.T) {
checkAssignment(t, strings.Repeat("a", 20000000))
}