-
Notifications
You must be signed in to change notification settings - Fork 39
/
issue125_test.go
58 lines (50 loc) · 1.41 KB
/
issue125_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
55
56
57
58
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package imagecashletter
import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestIssue125(t *testing.T) {
bs, err := os.ReadFile(filepath.Join("test", "testdata", "icl-valid.json"))
require.NoError(t, err)
file, err := FileFromJSON(bs)
require.NoError(t, err)
require.NotNil(t, file)
var buf bytes.Buffer
require.NoError(t, NewWriter(&buf).Write(file))
lines := strings.Split(buf.String(), "\n")
counts := make(map[string]int)
for i := range lines {
line := strings.TrimSpace(lines[i])
if line == "" {
continue
}
counts[line[:2]] += 1
}
// check each record count
assert.Equal(t, counts["01"], 1)
assert.Equal(t, counts["10"], 2)
assert.Equal(t, counts["20"], 4)
assert.Equal(t, counts["25"], 4)
assert.Equal(t, counts["26"], 4)
assert.Equal(t, counts["27"], 4)
assert.Equal(t, counts["28"], 4)
assert.Equal(t, counts["31"], 4)
assert.Equal(t, counts["32"], 4)
assert.Equal(t, counts["33"], 4)
assert.Equal(t, counts["34"], 4)
assert.Equal(t, counts["35"], 4)
assert.Equal(t, counts["50"], 8)
assert.Equal(t, counts["52"], 8)
assert.Equal(t, counts["54"], 8)
assert.Equal(t, counts["70"], 4)
assert.Equal(t, counts["90"], 2)
assert.Equal(t, counts["99"], 1)
}