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