-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathrange_test.go
More file actions
32 lines (26 loc) · 881 Bytes
/
range_test.go
File metadata and controls
32 lines (26 loc) · 881 Bytes
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
package tiledb
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRange(t *testing.T) {
r := MakeRange(uint8(10), uint8(20))
iBounds, err := ExtractRange[uint8](r)
require.NoError(t, err)
assert.Equal(t, uint8(10), iBounds[0])
assert.Equal(t, uint8(20), iBounds[1])
// extract for other types should fail
_, err = ExtractRange[uint16](r)
require.Error(t, err)
assert.Contains(t, err.Error(), "cannot extract a range of uint8 to a slice of uint16")
s := MakeRange("start", "end")
sBounds, err := ExtractRange[string](s)
require.NoError(t, err)
assert.Equal(t, "start", sBounds[0])
assert.Equal(t, "end", sBounds[1])
// extract for other types should fail
_, err = ExtractRange[uint16](s)
require.Error(t, err)
assert.Contains(t, err.Error(), "cannot extract a range of string to a slice of uint16")
}