Skip to content

Commit

Permalink
test: updates after requiring error in NewTagMaxLengthErr(..)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Jun 6, 2023
1 parent df51ffb commit 17baa04
Show file tree
Hide file tree
Showing 57 changed files with 172 additions and 110 deletions.
3 changes: 2 additions & 1 deletion accountCreditedDrawdown_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -94,7 +95,7 @@ func TestStringAccountCreditedDrawdownVariableLength(t *testing.T) {
r.line = line

err = r.parseAccountCreditedDrawdown()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{5400} *"
r = NewReader(strings.NewReader(line))
Expand Down
3 changes: 2 additions & 1 deletion accountDebitedDrawdown_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -179,7 +180,7 @@ func TestStringAccountDebitedDrawdownVariableLength(t *testing.T) {
r.line = line

err = r.parseAccountDebitedDrawdown()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{4400}***"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions actualAmountPaid_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -115,14 +116,14 @@ func TestStringActualAmountPaidVariableLength(t *testing.T) {
r.line = line

err = r.parseActualAmountPaid()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{8450}****"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseActualAmountPaid()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{8450}**"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions adjustment_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -158,14 +159,14 @@ func TestStringAdjustmentVariableLength(t *testing.T) {
r.line = line

err = r.parseAdjustment()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{8600}01CRDTUSD1234.56****"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseAdjustment()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{8600}01CRDTUSD1234.56*"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions amountNegotiatedDiscount_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -115,14 +116,14 @@ func TestStringAmountNegotiatedDiscountVariableLength(t *testing.T) {
r.line = line

err = r.parseAmountNegotiatedDiscount()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{8550}USD1234.56***"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseAmountNegotiatedDiscount()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{8550}USD1234.56*"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions beneficiaryCustomer_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -148,14 +149,14 @@ func TestStringBeneficiaryCustomerVariableLength(t *testing.T) {
r.line = line

err = r.parseBeneficiaryCustomer()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{7059}********"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseBeneficiaryCustomer()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{7059}******"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions beneficiaryFI_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -169,14 +170,14 @@ func TestStringBeneficiaryFIVariableLength(t *testing.T) {
r.line = line

err = r.parseBeneficiaryFI()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{4100}D123456789*******"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseBeneficiaryFI()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{4100}D123456789****"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions beneficiaryIntermediaryFI_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -172,14 +173,14 @@ func TestStringBeneficiaryIntermediaryFIVariableLength(t *testing.T) {
r.line = line

err = r.parseBeneficiaryIntermediaryFI()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{4000}D123456789*******"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseBeneficiaryIntermediaryFI()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{4000}D123456789****"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions beneficiaryReference_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -83,14 +84,14 @@ func TestStringBeneficiaryReferenceVariableLength(t *testing.T) {
r.line = line

err = r.parseBeneficiaryReference()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{4320}***"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseBeneficiaryReference()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{4320}*"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions beneficiary_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -159,14 +160,14 @@ func TestStringBeneficiaryVariableLength(t *testing.T) {
r.line = line

err = r.parseBeneficiary()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{4200}31234*******"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseBeneficiary()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{4200}31234*****"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions businessFunctionCode_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -95,14 +96,14 @@ func TestStringBusinessFunctionCodeVariableLength(t *testing.T) {
r.line = line

err = r.parseBusinessFunctionCode()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{3600}BTR***"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseBusinessFunctionCode()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{3600}BTR*"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions charges_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -58,14 +59,14 @@ func TestStringChargesVariableLength(t *testing.T) {
r.line = line

err = r.parseCharges()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{3700}B******"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseCharges()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{3700}B*"
r = NewReader(strings.NewReader(line))
Expand Down
3 changes: 1 addition & 2 deletions converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"strconv"
"strings"
"unicode/utf8"
)

// converters handles golang to WIRE type Converters
Expand Down Expand Up @@ -153,7 +152,7 @@ func (c *converters) stripDelimiters(data string) string {

// verify input data with read length
func (c *converters) verifyDataWithReadLength(data string, expected int) error {
n := utf8.RuneCountInString(data)
n := len(data) // utf8.RuneCountInString(data)
if n == expected {
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion currencyInstructedAmount_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -96,7 +97,7 @@ func TestStringCurrencyInstructedAmountVariableLength(t *testing.T) {
r.line = line

err = r.parseCurrencyInstructedAmount()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())
}

// TestStringCurrencyInstructedAmountOptions validates Format() formatted according to the FormatOptions
Expand Down
5 changes: 3 additions & 2 deletions errorWire_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -63,14 +64,14 @@ func TestStringErrorWireAmountVariableLength(t *testing.T) {
r.line = line

err = r.parseErrorWire()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{1130}1XYZData Error***"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseErrorWire()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{1130}1XYZData Error*"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions exchangeRate_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -85,14 +86,14 @@ func TestStringErrorExchangeRateVariableLength(t *testing.T) {
r.line = line

err = r.parseExchangeRate()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{3720}123***"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseExchangeRate()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{3720}123*"
r = NewReader(strings.NewReader(line))
Expand Down
5 changes: 3 additions & 2 deletions fIBeneficiaryFIAdvice_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wire

import (
"errors"
"strings"
"testing"

Expand Down Expand Up @@ -149,14 +150,14 @@ func TestStringFIBeneficiaryFIAdviceVariableLength(t *testing.T) {
r.line = line

err = r.parseFIBeneficiaryFIAdvice()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{6310}HLD********"
r = NewReader(strings.NewReader(line))
r.line = line

err = r.parseFIBeneficiaryFIAdvice()
require.EqualError(t, err, r.parseError(NewTagMaxLengthErr()).Error())
require.ErrorContains(t, err, r.parseError(NewTagMaxLengthErr(errors.New(""))).Error())

line = "{6310}HLD*"
r = NewReader(strings.NewReader(line))
Expand Down
Loading

0 comments on commit 17baa04

Please sign in to comment.