forked from makiuchi-d/gozxing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format_exception_test.go
41 lines (35 loc) · 981 Bytes
/
format_exception_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
39
40
41
package gozxing
import (
"errors"
"testing"
)
func TestFormatException(t *testing.T) {
var e error = GetFormatExceptionInstance()
if _, ok := e.(FormatException); !ok {
t.Fatalf("Type is not FormatException")
}
if _, ok := e.(ReaderException); !ok {
t.Fatalf("Type is not ReaderException")
}
if _, ok := e.(NotFoundException); ok {
t.Fatalf("Type must not be NotFoundException")
}
e.(FormatException).FormatException()
e.(FormatException).ReaderException()
}
func TestNewFormatException(t *testing.T) {
base := errors.New("newformatexception")
var e error = NewFormatExceptionInstance(base)
if _, ok := e.(FormatException); !ok {
t.Fatalf("Type is not FormatException")
}
if _, ok := e.(ReaderException); !ok {
t.Fatalf("Type is not ReaderException")
}
if _, ok := e.(NotFoundException); ok {
t.Fatalf("Type must not be NotFoundException")
}
if e.Error() != base.Error() {
t.Fatalf("e.Error() = %v, expect %v", e.Error(), base.Error())
}
}