Created
October 30, 2016 18:39
-
-
Save danmux/8e4e727ac36dcada592c882cd2384e9a to your computer and use it in GitHub Desktop.
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
package iban | |
import "testing" | |
import "reflect" | |
func TestParseDE(t *testing.T) { | |
fix := []struct { | |
in string | |
iban Iban | |
err bool | |
}{ | |
{ | |
in: "DE10123", | |
iban: Iban{CountryCode: "DE", CheckDigits: "10", Bban: "123"}, | |
err: false, | |
}, | |
{ | |
in: "DE10", | |
iban: Iban{CountryCode: "", CheckDigits: "", Bban: ""}, | |
err: true, | |
}, | |
} | |
for i, f := range fix { | |
ib, err := Parse(f.in) | |
if f.err && err == nil { | |
t.Error("expected error") | |
} | |
if !f.err && err != nil { | |
t.Error("got error", err) | |
} | |
if !reflect.DeepEqual(ib, f.iban) { | |
t.Errorf("%d, parsed iban %v not as expected %v", i, ib, f.iban) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment