-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make experiment with simplified structs work
- Loading branch information
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package iso8583_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/moov-io/iso8583" | ||
"github.com/moov-io/iso8583/specs" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestStructWithTypes(t *testing.T) { | ||
type authRequestData struct { | ||
MTI string `index:"0"` | ||
PrimaryAccountNumber string `index:"2"` | ||
ProcessingCode int `index:"3"` | ||
} | ||
|
||
t.Run("pack", func(t *testing.T) { | ||
authRequest := &authRequestData{ | ||
MTI: "0110", | ||
PrimaryAccountNumber: "4242424242424242", | ||
ProcessingCode: 200000, | ||
} | ||
|
||
message := iso8583.NewMessage(specs.Spec87ASCII) | ||
err := message.Marshal(authRequest) | ||
require.NoError(t, err) | ||
|
||
packed, err := message.Pack() | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, "011060000000000000000000000000000000164242424242424242200000", string(packed)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters