-
Notifications
You must be signed in to change notification settings - Fork 51
/
blocksize_test.go
54 lines (47 loc) · 1.02 KB
/
blocksize_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
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
/*
to run tests:
go test blocksize.go blocksize_test.go
*/
import "testing"
type blockSizeTestCase struct {
dasdName string
lrecl int
expectedBlockSize int
shouldError bool
}
var btcs = []*blockSizeTestCase{
{
dasdName: "2311",
lrecl: 10,
expectedBlockSize: 1810,
shouldError: false,
},
{
dasdName: "i don't exist",
lrecl: 0,
shouldError: true,
},
{
dasdName: "3390",
lrecl: 23,
expectedBlockSize: 28313,
shouldError: false,
},
}
func Test_getBlockSize(t *testing.T) {
for _, btc := range btcs {
actual, err := getBlockSize(btc.dasdName, btc.lrecl)
switch {
case err != nil && !btc.shouldError:
t.Fatalf("unexpected error in %v: %v", btc, err)
case err == nil && btc.shouldError:
t.Fatalf("missing error in %v", btc)
case err != nil && btc.shouldError:
default:
if actual != btc.expectedBlockSize {
t.Fatalf("incorrect block size in %v: %d", btc, actual)
}
}
}
}