navidrome/utils/utils_test.go

44 lines
1.0 KiB
Go
Raw Normal View History

2016-03-01 18:43:55 +01:00
package utils
import (
. "github.com/smartystreets/goconvey/convey"
2016-03-02 19:18:39 +01:00
"testing"
2016-03-01 18:43:55 +01:00
)
2016-03-01 23:07:13 +01:00
func TestParseIndexGroup(t *testing.T) {
2016-03-01 18:43:55 +01:00
2016-03-01 23:07:13 +01:00
Convey("Two simple entries", t, func() {
parsed := ParseIndexGroups("A The")
2016-03-01 18:43:55 +01:00
2016-03-01 23:07:13 +01:00
So(parsed, ShouldContainKey, "A")
So(parsed["A"], ShouldEqual, "A")
So(parsed, ShouldContainKey, "The")
So(parsed["The"], ShouldEqual, "The")
})
Convey("An entry with a group", t, func() {
parsed := ParseIndexGroups("A-C(ABC) Z")
So(parsed, ShouldContainKey, "A")
So(parsed["A"], ShouldEqual, "A-C")
So(parsed, ShouldContainKey, "B")
So(parsed["B"], ShouldEqual, "A-C")
So(parsed, ShouldContainKey, "C")
So(parsed["C"], ShouldEqual, "A-C")
So(parsed["Z"], ShouldEqual, "Z")
})
Convey("Correctly parses UTF-8", t, func() {
parsed := ParseIndexGroups("UTF8(宇A海)")
So(parsed, ShouldContainKey, "宇")
So(parsed["宇"], ShouldEqual, "UTF8")
So(parsed, ShouldContainKey, "A")
So(parsed["A"], ShouldEqual, "UTF8")
So(parsed, ShouldContainKey, "海")
So(parsed["海"], ShouldEqual, "UTF8")
})
2016-03-02 19:18:39 +01:00
}