Skip to content

Commit

Permalink
test: verify rtp.Amount marshals large amounts in decimal notation
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Jan 12, 2024
1 parent 364e0a3 commit f8033da
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/rtp/amount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package rtp_test

import (
"encoding/xml"
"testing"

"github.com/moov-io/rtp20022/pkg/rtp"

"github.com/stretchr/testify/require"
"testing"
)

func TestAmountFormat(t *testing.T) {
Expand All @@ -23,6 +25,13 @@ func TestAmountFormat(t *testing.T) {
err = xml.Unmarshal([]byte(amtTag), &read)
require.NoError(t, err)
require.Equal(t, amt, read)

t.Run("large", func(t *testing.T) {
amt = rtp.Amount(1_252_363.25)
bs, err := xml.Marshal(amt)
require.NoError(t, err)
require.Equal(t, "<Amount>1252363.25</Amount>", string(bs))
})
}

func TestAmountValidate(t *testing.T) {
Expand Down

0 comments on commit f8033da

Please sign in to comment.