-
Notifications
You must be signed in to change notification settings - Fork 16
/
error_test.go
38 lines (30 loc) · 898 Bytes
/
error_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
package sarah
import (
"strconv"
"strings"
"testing"
)
func TestNewBlockedInputError(t *testing.T) {
i := 123
err := NewBlockedInputError(i)
if err == nil {
t.Fatal("Instance of BlockedInputError is not returned.")
}
if _, ok := err.(*BlockedInputError); !ok {
t.Fatalf("Returned value is not instance of BBlockedInputError: %#v", err)
}
concreteErr := err.(*BlockedInputError)
if concreteErr.ContinuationCount != i {
t.Errorf("Returned instance has different count than expected one. Expected: %d. Returned: %d.", i, concreteErr.ContinuationCount)
}
}
func TestBlockedInputError_Error(t *testing.T) {
i := 123
err := NewBlockedInputError(i)
if err == nil {
t.Fatal("Expected error instance is not returned.")
}
if !strings.Contains(err.Error(), strconv.Itoa(i)) {
t.Errorf("Returned string does not contain the count of error occurrence: %s.", err.Error())
}
}