func TestDates(t *testing.T) { for _, lang := range fake.GetLangs() { fake.SetLang(lang) from, _ := time.Parse("2006-01-02T15:04:05", "2016-01-01T00:00:00") to, _ := time.Parse("2006-01-02T15:04:05", "2016-01-31T23:59:59") d := fake.Time(from, to) if !from.Equal(d) && !from.Before(d) { t.Errorf("Time before from date %s", lang) } if !to.Equal(d) && !to.After(d) { t.Errorf("Time after %s to date %s", d, lang) } v := fake.WeekDay() if v == "" { t.Errorf("WeekDay failed with lang %s", lang) } v = fake.WeekDayShort() if v == "" { t.Errorf("WeekDayShort failed with lang %s", lang) } n := fake.WeekdayNum() if n < 0 || n > 7 { t.Errorf("WeekdayNum failed with lang %s", lang) } v = fake.Month() if v == "" { t.Errorf("Month failed with lang %s", lang) } v = fake.MonthShort() if v == "" { t.Errorf("MonthShort failed with lang %s", lang) } n = fake.MonthNum() if n < 0 || n > 31 { t.Errorf("MonthNum failed with lang %s", lang) } n = fake.Year(1950, 2020) if n < 1950 || n > 2020 { t.Errorf("Year failed with lang %s", lang) } } }
func TestAddresses(t *testing.T) { for _, lang := range fake.GetLangs() { fake.SetLang(lang) v := fake.Continent() if v == "" { t.Errorf("Continent failed with lang %s", lang) } v = fake.Country() if v == "" { t.Errorf("Country failed with lang %s", lang) } v = fake.City() if v == "" { t.Errorf("City failed with lang %s", lang) } v = fake.State() if v == "" { t.Errorf("State failed with lang %s", lang) } v = fake.StateAbbrev() if v == "" && lang == "en" { t.Errorf("StateAbbrev failed with lang %s", lang) } v = fake.Street() if v == "" { t.Errorf("Street failed with lang %s", lang) } v = fake.StreetAddress() if v == "" { t.Errorf("StreetAddress failed with lang %s", lang) } v = fake.Zip() if v == "" { t.Errorf("Zip failed with lang %s", lang) } v = fake.Phone() if v == "" { t.Errorf("Phone failed with lang %s", lang) } } }
func TestCurrencies(t *testing.T) { for _, lang := range fake.GetLangs() { fake.SetLang(lang) v := fake.Currency() if v == "" { t.Errorf("Currency failed with lang %s", lang) } v = fake.CurrencyCode() if v == "" { t.Errorf("CurrencyCode failed with lang %s", lang) } } }
func TestCreditCards(t *testing.T) { for _, lang := range fake.GetLangs() { fake.SetLang(lang) v := fake.CreditCardType() if v == "" { t.Errorf("CreditCardType failed with lang %s", lang) } v = fake.CreditCardNum("") if v == "" { t.Errorf("CreditCardNum failed with lang %s", lang) } v = fake.CreditCardNum("visa") if v == "" { t.Errorf("CreditCardNum failed with lang %s", lang) } } }