-
Notifications
You must be signed in to change notification settings - Fork 34
/
list-processing_test.go
43 lines (34 loc) · 1.11 KB
/
list-processing_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
package roger
import (
"reflect"
"runtime/debug"
"testing"
)
func checkList(t *testing.T, rstring string, result interface{}) {
defer func() {
if r := recover(); r != nil {
t.Error("Panic during test. ", r, string(debug.Stack()))
}
}()
con, err := NewRClient("localhost", 6311)
if err != nil {
t.Error("Could not connect to RServe: " + err.Error())
return
}
v, err := con.Eval(rstring)
if err != nil {
t.Error("Error returned by R: " + err.Error())
}
if !reflect.DeepEqual(v, result) {
t.Error("Actual result did not match expected result.")
}
}
func TestListFloatInts(t *testing.T) {
checkList(t, "list(int=1,string='s',float=0.5)", map[string]interface{}{"int": 1.0, "string": "s", "float": 0.5})
}
func TestListBoolInMiddle(t *testing.T) {
checkList(t, "list(int=1,string='s',float=0.5,bool=TRUE,anything='this should not cause a panic')", map[string]interface{}{"int": 1.0, "string": "s", "bool": true, "float": 0.5, "anything": "this should not cause a panic"})
}
func TestOnlyBool(t *testing.T) {
checkList(t, "list(bool=TRUE,b2=FALSE)", map[string]interface{}{"bool": true, "b2": false})
}