Documentation, tests, tweaks.

This commit is contained in:
Nuno Cruces
2023-03-07 14:45:54 +00:00
parent f5747f19fb
commit 5d6f92b733
4 changed files with 16 additions and 22 deletions

View File

@@ -1,7 +1,6 @@
package sqlite3
import (
"context"
"errors"
"strings"
"testing"
@@ -9,7 +8,7 @@ import (
func Test_assertErr(t *testing.T) {
err := assertErr()
if s := err.Error(); !strings.HasPrefix(s, "sqlite3: assertion failed") || !strings.HasSuffix(s, "error_test.go:11)") {
if s := err.Error(); !strings.HasPrefix(s, "sqlite3: assertion failed") || !strings.HasSuffix(s, "error_test.go:10)") {
t.Errorf("got %q", s)
}
}
@@ -120,10 +119,8 @@ func Test_ErrorCode_Error(t *testing.T) {
// Test all error codes.
for i := 0; i == int(ErrorCode(i)); i++ {
want := "sqlite3: "
r, _ := db.api.errstr.Call(context.TODO(), uint64(i))
if r != nil {
want += db.mem.readString(uint32(r[0]), _MAX_STRING)
}
r := db.call(db.api.errstr, uint64(i))
want += db.mem.readString(uint32(r[0]), _MAX_STRING)
got := ErrorCode(i).Error()
if got != want {
@@ -144,10 +141,8 @@ func Test_ExtendedErrorCode_Error(t *testing.T) {
// Test all extended error codes.
for i := 0; i == int(ExtendedErrorCode(i)); i++ {
want := "sqlite3: "
r, _ := db.api.errstr.Call(context.TODO(), uint64(i))
if r != nil {
want += db.mem.readString(uint32(r[0]), _MAX_STRING)
}
r := db.call(db.api.errstr, uint64(i))
want += db.mem.readString(uint32(r[0]), _MAX_STRING)
got := ExtendedErrorCode(i).Error()
if got != want {