Skip to content

Instantly share code, notes, and snippets.

@danmux
Created October 30, 2016 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danmux/c805910f0727698581696f6e715843c0 to your computer and use it in GitHub Desktop.
Save danmux/c805910f0727698581696f6e715843c0 to your computer and use it in GitHub Desktop.
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