-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathresult_test.go
More file actions
36 lines (28 loc) · 763 Bytes
/
result_test.go
File metadata and controls
36 lines (28 loc) · 763 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
33
34
35
36
// Copyright 2021 Roxy Light
// SPDX-License-Identifier: ISC
package sqlite
import "testing"
func TestResultCodeMessage(t *testing.T) {
t.Log(ResultOK.Message())
t.Log(ResultNoMem.Message())
}
func TestErrCode(t *testing.T) {
rawErr := ResultInterrupt.ToError()
if got, want := ErrCode(rawErr), ResultInterrupt; got != want {
t.Errorf("got err=%s, want %s", got, want)
}
wrappedErr := errWithMessage{err: rawErr, msg: "Doing something"}
if got, want := ErrCode(wrappedErr), ResultInterrupt; got != want {
t.Errorf("got err=%s, want %s", got, want)
}
}
type errWithMessage struct {
err error
msg string
}
func (e errWithMessage) Unwrap() error {
return e.err
}
func (e errWithMessage) Error() string {
return e.msg + ": " + e.err.Error()
}