Skip to content

Commit

Permalink
Add all present abbreviations to test; Validate timezones with time.L…
Browse files Browse the repository at this point in the history
…oadLocation tkuchiki#6
  • Loading branch information
Alexander Baranov committed Jun 6, 2019
1 parent b2d1f05 commit bf9a41e
Showing 1 changed file with 189 additions and 1 deletion.
190 changes: 189 additions & 1 deletion timezone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package timezone

import (
"testing"
"time"
)

var timezoneShorts = []string{
Expand Down Expand Up @@ -55,14 +56,201 @@ var timezoneShorts = []string{
"UTC−4",
"WAT",
"WEST",
"GMT+12",
"GMT+11",
"NUT",
"SST",
"CKT",
"GMT+10",
"HST",
"TAHT",
"MART",
"AKST",
"GAMT",
"GMT+9",
"GMT+8",
"PST",
"GMT+7",
"MST",
"CST",
"GALT",
"GMT+6",
"ACT",
"COT",
"EAST",
"ECT",
"EST",
"GMT+5",
"PET",
"VET",
"AMT",
"AST",
"BOT",
"GMT+4",
"GYT",
"NST",
"ART",
"BRT",
"CLT",
"FKST",
"GFT",
"GMT+3",
"PMST",
"PYST",
"ROTT",
"SRT",
"WGT",
"FNT",
"GMT+2",
"UYST",
"AZOT",
"CVT",
"EGT",
"GMT+1",
"GMT",
"UCT",
"UTC",
"WET",
"CET",
"GMT-1",
"MET",
"WAT",
"CAT",
"EET",
"GMT-2",
"SAST",
"WAST",
"EAT",
"GMT-3",
"MSK",
"SYOT",
"IRST",
"AZT",
"GET",
"GMT-4",
"GST",
"MUT",
"RET",
"SAMT",
"SCT",
"AFT",
"AQTT",
"GMT-5",
"MAWT",
"MVT",
"ORAT",
"PKT",
"TFT",
"TJT",
"TMT",
"UZT",
"YEKT",
"IST",
"NPT",
"ALMT",
"BDT",
"BTT",
"GMT-6",
"IOT",
"KGT",
"NOVT",
"OMST",
"QYZT",
"VOST",
"XJT",
"CCT",
"MMT",
"CXT",
"DAVT",
"GMT-7",
"HOVT",
"ICT",
"KRAT",
"WIB",
"AWST",
"BNT",
"CHOT",
"GMT-8",
"HKT",
"IRKT",
"MYT",
"PHT",
"SGT",
"ULAT",
"WITA",
"ACWST",
"GMT-9",
"JST",
"KST",
"PWT",
"TLT",
"WIT",
"YAKT",
"ACST",
"AEST",
"CHUT",
"ChST",
"DDUT",
"GMT-10",
"MAGT",
"PGT",
"SAKT",
"VLAT",
"ACDT",
"AEDT",
"BST",
"GMT-11",
"KOST",
"LHDT",
"MIST",
"NCT",
"PONT",
"SBT",
"SRET",
"VUT",
"NFT",
"ANAT",
"FJT",
"GILT",
"GMT-12",
"MHT",
"NRT",
"PETT",
"TVT",
"WAKT",
"WFT",
"GMT-13",
"NZDT",
"PHOT",
"TKT",
"TOT",
"CHADT",
"GMT-14",
"LINT",
"WSDT",
}

func TestAbbreviations(t *testing.T) {
for _, abbr := range timezoneShorts {
_, err := GetTimezones(abbr)
foundTimezones, err := GetTimezones(abbr)
if err != nil {
t.Errorf("Error loading short timezone %s: %v", abbr, err)
continue
}

if len(foundTimezones) == 0 {
t.Errorf("Empty timezones list in %s", abbr)
continue
}

for _, tz := range foundTimezones {
loc, err := time.LoadLocation(tz)
if err != nil {
t.Errorf("Error loading location: %s -> %s", abbr, tz)
}
if loc == nil {
t.Errorf("Nil location for %s -> %s", abbr, tz)
}
}
}
}

0 comments on commit bf9a41e

Please sign in to comment.