Commit 0b10a6cd authored by gwenn's avatar gwenn

Add scan test.

parent 0cf2b8a4
......@@ -304,16 +304,36 @@ func TestScanNull(t *testing.T) {
if !Must(s.Next()) {
t.Fatal("no result")
}
var pi *int
var pi *int = new(int)
null := Must(s.ScanByIndex(0, &pi))
assert(t, "expected null value", null)
assertEquals(t, "expected nil (%p) but got %p", (*int)(nil), pi)
var ps *string
var ps *string = new(string)
null = Must(s.ScanByIndex(0, &ps))
assert(t, "expected null value", null)
assertEquals(t, "expected nil (%p) but got %p", (*string)(nil), ps)
}
func TestScanNotNull(t *testing.T) {
db := open(t)
defer db.Close()
s, err := db.Prepare("select 1")
checkNoError(t, err, "prepare error: %s")
defer s.Finalize()
if !Must(s.Next()) {
t.Fatal("no result")
}
var pi *int = new(int)
null := Must(s.ScanByIndex(0, &pi))
assert(t, "expected not null value", !null)
assertEquals(t, "expected %d but got %d", 1, *pi)
var ps *string = new(string)
null = Must(s.ScanByIndex(0, &ps))
assert(t, "expected not null value", !null)
assertEquals(t, "expected %s but got %s", "1", *ps)
}
func TestCloseTwice(t *testing.T) {
db := open(t)
s, err := db.Prepare("SELECT 1")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment