test: verify all return codes generate proper lenght records
We've heard a report of R06 codes generating incorrect length records.
@@ -21,8 +21,11 @@ import (
"path/filepath"
"strings"
"testing"
+ "unicode/utf8"
"github.com/moov-io/base"
+
+ "github.com/stretchr/testify/require"
)
func mockAddenda99() *Addenda99 {
@@ -121,6 +124,19 @@ func BenchmarkAddenda99String(b *testing.B) {
}
}
+func TestAddenda99AllReturnCodes(t *testing.T) {
+ for code, _ := range returnCodeDict {
+ addenda99 := mockAddenda99()
+ addenda99.ReturnCode = code
+
+ require.NoError(t, addenda99.Validate())
+
+ line := addenda99.String()
+ require.Equal(t, 94, len(line))
+ require.Equal(t, 94, utf8.RuneCountInString(line))
+ }
+}
+
// This is not an exported function but utilized for validation
func testAddenda99MakeReturnCodeDict(t testing.TB) {
codes := makeReturnCodeDict()
