Skip to content

Instantly share code, notes, and snippets.

@danmux
Created October 30, 2016 18:38
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/64b4c47b2b25676adb7b3c18ac6193ac to your computer and use it in GitHub Desktop.
Save danmux/64b4c47b2b25676adb7b3c18ac6193ac to your computer and use it in GitHub Desktop.
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