Created
October 30, 2016 18:38
-
-
Save danmux/64b4c47b2b25676adb7b3c18ac6193ac 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" | |
func TestParse(t *testing.T) { | |
// Valid IBAN | |
iban, err := Parse("DE10123") | |
if err != nil { | |
t.Error(err.Error()) | |
} | |
if iban.CountryCode != "DE" { | |
t.Error("got wrong CountryCode") | |
} | |
if iban.CheckDigits != "10" { | |
t.Error("got wrong CheckDigits") | |
} | |
if iban.Bban != "123" { | |
t.Error("got wrong Bban") | |
} | |
// Invalid IBAN | |
iban, err = Parse("DE10") | |
if err == nil { | |
t.Error("expected to get an error") | |
} | |
if iban.CountryCode != "" { | |
t.Error("got wrong CountryCode") | |
} | |
if iban.CheckDigits != "" { | |
t.Error("got wrong CheckDigits") | |
} | |
if iban.Bban != "" { | |
t.Error("got wrong Bban") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment