Skip to content

Instantly share code, notes, and snippets.

@danmux
Created October 30, 2016 18:44
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/e7fe6c833a784a94200f463ac197ca29 to your computer and use it in GitHub Desktop.
Save danmux/e7fe6c833a784a94200f463ac197ca29 to your computer and use it in GitHub Desktop.
package iban
import "testing"
func ibanParseEqual(t *testing.T, iban, cc, cd, bb string, willErr bool) {
got, err := Parse(iban)
if willErr && err == nil {
t.Error("expected error")
}
if !willErr && err != nil {
t.Error("got error", err)
}
if got.CountryCode != cc {
t.Error("got wrong CountryCode", got.CountryCode)
}
if got.CheckDigits != cd {
t.Error("got wrong CheckDigits", got.CheckDigits)
}
if got.Bban != bb {
t.Error("got wrong Bban", got.Bban)
}
}
func TestParseIbanEq(t *testing.T) {
// Valid IBAN
ibanParseEqual(t, "DE10123", "DE", "10", "123", false)
ibanParseEqual(t, "DE10", "", "", "", true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment