-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_test.go
More file actions
38 lines (34 loc) · 945 Bytes
/
string_test.go
File metadata and controls
38 lines (34 loc) · 945 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
37
38
package decompressor
import (
"reflect"
"testing"
)
func TestToString(t *testing.T) {
for _, tt := range initTestCases() {
t.Run(tt.name, func(t *testing.T) {
defer func() {
r := recover()
if (r != nil) != tt.wantErr {
t.Errorf("ToString() should panic = %v, but it did = %v", tt.wantErr, r != nil)
}
}()
if gotRes := ToString(tt.compressType, tt.arg); !reflect.DeepEqual([]byte(gotRes), tt.want) {
t.Errorf("ToString() = %v, want %v", gotRes, tt.want)
}
})
}
}
func TestToStringWithErr(t *testing.T) {
for _, tt := range initTestCases() {
t.Run(tt.name, func(t *testing.T) {
got, err := ToStringWithErr(tt.compressType, tt.arg)
if (err != nil) != tt.wantErr {
t.Errorf("ToStringWithErr() error = %v, wantErr %v", err, tt.wantErr)
return
}
if err == nil && !reflect.DeepEqual([]byte(got), tt.want) {
t.Errorf("ToStringWithErr() = %v, want %v", got, tt.want)
}
})
}
}