| 1 |
package swift |
| 2 |
|
| 3 |
import ( |
| 4 |
"reflect" |
| 5 |
"testing" |
| 6 |
) |
| 7 |
|
| 8 |
func TestCustomFieldTagUnmarshal(t *testing.T) { |
| 9 |
test := ":86:123?00ABC?10xyz?20ah\r\nh?21hjj?301000?3156?32Max?33Muster?3499?60uu?61z\r\n4" |
| 10 |
|
| 11 |
expectedTag := &CustomFieldTag{ |
| 12 |
Tag: ":86:", |
| 13 |
TransactionID: 123, |
| 14 |
BookingText: "ABC", |
| 15 |
PrimanotenNumber: "xyz", |
| 16 |
Purpose: []string{"ahh", "hjj"}, |
| 17 |
BankID: "1000", |
| 18 |
AccountID: "56", |
| 19 |
Name: "Max Muster", |
| 20 |
MessageKeyAddition: 99, |
| 21 |
Purpose2: []string{"uu", "z4"}, |
| 22 |
} |
| 23 |
|
| 24 |
tag := &CustomFieldTag{} |
| 25 |
|
| 26 |
err := tag.Unmarshal([]byte(test)) |
| 27 |
|
| 28 |
if err != nil { |
| 29 |
t.Logf("Expected no error, got %T:%v\n", err, err) |
| 30 |
t.Fail() |
| 31 |
} |
| 32 |
|
| 33 |
if !reflect.DeepEqual(expectedTag, tag) { |
| 34 |
t.Logf("Expected tag to equal\n%#v\n\tgot\n%#v\n", expectedTag, tag) |
| 35 |
t.Fail() |
| 36 |
} |
| 37 |
} |