forked from minus5/gofreetds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sp_result_test.go
49 lines (42 loc) · 1 KB
/
sp_result_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
package freetds
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestSpResult(t *testing.T) {
r := NewSpResult()
assert.Equal(t, -1, r.status)
assert.Equal(t, -1, r.currentResult)
assert.False(t, r.HasOutputParams())
assert.False(t, r.HasResults())
assert.False(t, r.NextResult())
assert.Nil(t, r.Result())
}
func TestSpResultNextResult(t *testing.T) {
r := NewSpResult()
r1 := testResult()
r2 := testResult()
r.results = []*Result{r1, r2}
assert.Equal(t, 2, r.ResultsCount())
assert.True(t, r.HasResults())
assert.True(t, r.NextResult())
assert.True(t, r1 == r.Result())
assert.True(t, r.NextResult())
assert.True(t, r2 == r.Result())
assert.False(t, r.NextResult())
assert.Nil(t, r.Result())
}
func TestSpResultScan(t *testing.T) {
r := NewSpResult()
r1 := testResult()
r2 := testResult()
r.results = []*Result{r1, r2}
var i int
err := r.Scan(&i)
assert.Nil(t, err)
assert.Equal(t, i, 1)
assert.True(t, r.Next())
err = r.Scan(&i)
assert.Nil(t, err)
assert.Equal(t, i, 2)
}