Fix the time template func test

By making it not depend on the locale setup.
This commit is contained in:
Bjørn Erik Pedersen
2016-08-04 10:36:44 +02:00
parent 70544f9e62
commit 93f3a85bf8
3 changed files with 32 additions and 27 deletions

View File

@@ -467,3 +467,27 @@ func NormalizeHugoFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
}
return pflag.NormalizedName(name)
}
// DiffStringSlices returns the difference between two string slices.
// Useful in tests.
// See:
// http://stackoverflow.com/questions/19374219/how-to-find-the-difference-between-two-slices-of-strings-in-golang
func DiffStringSlices(slice1 []string, slice2 []string) []string {
diffStr := []string{}
m := map[string]int{}
for _, s1Val := range slice1 {
m[s1Val] = 1
}
for _, s2Val := range slice2 {
m[s2Val] = m[s2Val] + 1
}
for mKey, mVal := range m {
if mVal == 1 {
diffStr = append(diffStr, mKey)
}
}
return diffStr
}