forked from runabol/tork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncs_test.go
35 lines (26 loc) · 818 Bytes
/
funcs_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
package eval
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRange(t *testing.T) {
result := range_(1, 3)
assert.Equal(t, []int{1, 2}, result)
result = range_(-5, -2)
assert.Equal(t, []int{-5, -4, -3}, result)
result = range_(5, 2)
assert.Equal(t, []int{}, result)
result = range_(2, 2)
assert.Equal(t, []int{}, result)
}
func Test_parseJSON(t *testing.T) {
result, err := parseJSON(`{"hello":"world"}`)
assert.NoError(t, err)
assert.Equal(t, map[string]any{"hello": "world"}, result)
result, err = parseJSON(`{"somenumber":5}`)
assert.NoError(t, err)
assert.Equal(t, map[string]any{"somenumber": float64(5)}, result)
result, err = parseJSON(`[{"hello":"world"}]`)
assert.NoError(t, err)
assert.Equal(t, []interface{}{map[string]interface{}{"hello": "world"}}, result)
}