Commit 28ac60e4 authored by gwenn's avatar gwenn

Add some tests.

parent 50a64510
......@@ -15,7 +15,7 @@ See [package documentation](http://godoc.org/github.com/gwenn/gosqlite).
If your OS does not bundle SQLite3 development files (or old ones):
- download and copy SQLite3 files
```shell
```sh
$ cp ~/Downloads/sqlite-amalgamation-xxx/sqlite3.{c,h} $GOPATH/src/github.com/gwenn/gosqlite
```
......
......@@ -72,3 +72,20 @@ func TestBlobMisuse(t *testing.T) {
/*err = bw.Close()
assert(t, "error expected", err != nil)*/
}
func TestZeroLengthBlob(t *testing.T) {
db := open(t)
defer checkClose(db, t)
err := db.Exec("CREATE TABLE test (content BLOB);")
checkNoError(t, err, "error creating table: %s")
err = db.Exec("INSERT INTO test VALUES (?)", ZeroBlobLength(0))
checkNoError(t, err, "insert error: %s")
rowid := db.LastInsertRowid()
var blob []byte
err = db.OneValue("SELECT content FROM test WHERE rowid = ?", &blob, rowid)
checkNoError(t, err, "select error: %s")
assert(t, "nil blob expected", blob == nil)
}
......@@ -453,3 +453,18 @@ func TestBindEmptyZeroNotTransformedToNull(t *testing.T) {
_, null = s.ScanValue(1, false)
assert(t, "Zero time expected", !null)
}
func TestColumnType(t *testing.T) {
db := open(t)
defer checkClose(db, t)
createTable(db, t)
s, err := db.Prepare("SELECT * from test")
checkNoError(t, err, "prepare error: %s")
defer checkFinalize(s, t)
for col := 0; col < s.ColumnCount(); col++ {
//println(col, s.ColumnName(col), s.ColumnOriginName(col), s.ColumnType(col), s.ColumnDeclaredType(col))
assertEquals(t, "expected %s but got %s type", Null, s.ColumnType(col))
}
}
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