update
Some checks failed
Pipeline: Test, Lint, Build / Get version info (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test JS code (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint i18n files (push) Has been cancelled
Pipeline: Test, Lint, Build / Check Docker configuration (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to GHCR (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Has been cancelled
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Has been cancelled
Pipeline: Test, Lint, Build / Build Windows installers (push) Has been cancelled
Pipeline: Test, Lint, Build / Package/Release (push) Has been cancelled
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
POEditor import / update-translations (push) Has been cancelled

This commit is contained in:
2025-12-08 16:16:23 +01:00
commit c251f174ed
1349 changed files with 194301 additions and 0 deletions

12
utils/number/number.go Normal file
View File

@@ -0,0 +1,12 @@
package number
import (
"strconv"
"golang.org/x/exp/constraints"
)
func ParseInt[T constraints.Integer](s string) T {
r, _ := strconv.ParseInt(s, 10, 64)
return T(r)
}

View File

@@ -0,0 +1,31 @@
package number_test
import (
"testing"
"github.com/navidrome/navidrome/utils/number"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestNumber(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Number Suite")
}
var _ = Describe("number package", func() {
Describe("ParseInt", func() {
It("should parse a string into an int", func() {
Expect(number.ParseInt[int64]("123")).To(Equal(int64(123)))
})
It("should parse a string into an int32", func() {
Expect(number.ParseInt[int32]("123")).To(Equal(int32(123)))
})
It("should parse a string into an int64", func() {
Expect(number.ParseInt[int]("123")).To(Equal(123))
})
It("should parse a string into an uint", func() {
Expect(number.ParseInt[uint]("123")).To(Equal(uint(123)))
})
})
})