working sections version

This commit is contained in:
ston1th 2019-03-27 23:08:59 +01:00
commit 9424084a36
28 changed files with 367 additions and 251 deletions

View file

@ -48,7 +48,11 @@ func StoreTitle(section, title string) string {
}
func SplitStoreTitle(st string) (section, title string) {
if a := strings.Split(st, "/"); len(a) == 2 {
a := strings.Split(st, "/")
switch len(a) {
case 1:
return a[0], ""
case 2:
return a[0], a[1]
}
return

View file

@ -21,6 +21,12 @@ func TestTitleFunctions(t *testing.T) {
t.Fail()
}
})
t.Run("SplitStoreTitleSingle", func(t *testing.T) {
se, ti := SplitStoreTitle(section)
if se != section || ti != "" {
t.Fail()
}
})
t.Run("Title", func(t *testing.T) {
if Title("9ßw$%4h4t-8v74 287(G /SV&3[45v}=94#+?)") != "9w4h4t-8v74+287G+SV345v94" {
t.Fail()