mirror of
https://github.com/navidrome/navidrome.git
synced 2026-06-02 07:01:36 +00:00
test: use local pointer helpers for lyrics tests
This commit is contained in:
parent
0100e8893a
commit
0f3042b996
@ -4,7 +4,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/utils/gg"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
@ -37,8 +36,8 @@ var _ = Describe("ParseEmbedded", func() {
|
||||
Expect(list[0].Synced).To(BeTrue())
|
||||
Expect(list[0].Agents).To(Equal([]model.Agent{{ID: "lead", Role: "main", Name: "Lead Vocal"}}))
|
||||
Expect(list[0].Line).To(HaveLen(1))
|
||||
Expect(list[0].Line[0].Start).To(Equal(gg.P(int64(1000))))
|
||||
Expect(list[0].Line[0].End).To(Equal(gg.P(int64(3000))))
|
||||
Expect(list[0].Line[0].Start).To(Equal(ptr(int64(1000))))
|
||||
Expect(list[0].Line[0].End).To(Equal(ptr(int64(3000))))
|
||||
Expect(list[0].Line[0].Value).To(Equal("Hello world"))
|
||||
Expect(list[0].Line[0].Cue).To(HaveLen(2))
|
||||
Expect(list[0].Line[0].Cue[0].AgentID).To(Equal("lead"))
|
||||
@ -106,13 +105,13 @@ Another subtitle line`
|
||||
Lang: "por",
|
||||
Line: []model.Line{
|
||||
{
|
||||
Start: gg.P(int64(18800)),
|
||||
End: gg.P(int64(22800)),
|
||||
Start: ptr(int64(18800)),
|
||||
End: ptr(int64(22800)),
|
||||
Value: "We're from subtitles",
|
||||
},
|
||||
{
|
||||
Start: gg.P(int64(22801)),
|
||||
End: gg.P(int64(26000)),
|
||||
Start: ptr(int64(22801)),
|
||||
End: ptr(int64(26000)),
|
||||
Value: "Another subtitle line",
|
||||
},
|
||||
},
|
||||
|
||||
5
core/lyrics/external_test_helpers_test.go
Normal file
5
core/lyrics/external_test_helpers_test.go
Normal file
@ -0,0 +1,5 @@
|
||||
package lyrics_test
|
||||
|
||||
func ptr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
@ -51,20 +51,20 @@ var _ = Describe("sources", func() {
|
||||
Lang: "eng",
|
||||
Line: []model.Line{
|
||||
{
|
||||
Start: gg.P(int64(1000)),
|
||||
End: gg.P(int64(3000)),
|
||||
Start: ptr(int64(1000)),
|
||||
End: ptr(int64(3000)),
|
||||
Value: "Lead words",
|
||||
Cue: []model.Cue{
|
||||
{
|
||||
Start: gg.P(int64(1000)),
|
||||
End: gg.P(int64(1500)),
|
||||
Start: ptr(int64(1000)),
|
||||
End: ptr(int64(1500)),
|
||||
Value: "Lead ",
|
||||
ByteStart: 0,
|
||||
ByteEnd: 4,
|
||||
},
|
||||
{
|
||||
Start: gg.P(int64(1500)),
|
||||
End: gg.P(int64(3000)),
|
||||
Start: ptr(int64(1500)),
|
||||
End: ptr(int64(3000)),
|
||||
Value: "words",
|
||||
ByteStart: 5,
|
||||
ByteEnd: 9,
|
||||
@ -72,7 +72,7 @@ var _ = Describe("sources", func() {
|
||||
},
|
||||
},
|
||||
{
|
||||
Start: gg.P(int64(3000)),
|
||||
Start: ptr(int64(3000)),
|
||||
Value: "Fallback line",
|
||||
},
|
||||
},
|
||||
@ -86,11 +86,11 @@ var _ = Describe("sources", func() {
|
||||
Lang: "eng",
|
||||
Line: []model.Line{
|
||||
{
|
||||
Start: gg.P(int64(18800)),
|
||||
Start: ptr(int64(18800)),
|
||||
Value: "We're no strangers to love",
|
||||
},
|
||||
{
|
||||
Start: gg.P(int64(22800)),
|
||||
Start: ptr(int64(22800)),
|
||||
Value: "You know the rules and so do I",
|
||||
},
|
||||
},
|
||||
@ -101,7 +101,7 @@ var _ = Describe("sources", func() {
|
||||
Lang: "por",
|
||||
Line: []model.Line{
|
||||
{
|
||||
Start: gg.P(int64(18800)),
|
||||
Start: ptr(int64(18800)),
|
||||
Value: "Nao somos estranhos ao amor",
|
||||
},
|
||||
},
|
||||
@ -129,13 +129,13 @@ var _ = Describe("sources", func() {
|
||||
Lang: "xxx",
|
||||
Line: []model.Line{
|
||||
{
|
||||
Start: gg.P(int64(18800)),
|
||||
End: gg.P(int64(22800)),
|
||||
Start: ptr(int64(18800)),
|
||||
End: ptr(int64(22800)),
|
||||
Value: "We're from subtitles",
|
||||
},
|
||||
{
|
||||
Start: gg.P(int64(22801)),
|
||||
End: gg.P(int64(26000)),
|
||||
Start: ptr(int64(22801)),
|
||||
End: ptr(int64(26000)),
|
||||
Value: "Another subtitle line",
|
||||
},
|
||||
},
|
||||
|
||||
@ -100,40 +100,40 @@ var _ = Describe("sources", func() {
|
||||
Expect(lyrics[0].Line).To(HaveLen(3))
|
||||
|
||||
// Line 1: has inline markers → Cue array populated
|
||||
Expect(lyrics[0].Line[0].Start).To(Equal(gg.P(int64(1000))))
|
||||
Expect(lyrics[0].Line[0].End).To(Equal(gg.P(int64(3000))))
|
||||
Expect(lyrics[0].Line[0].Start).To(Equal(ptr(int64(1000))))
|
||||
Expect(lyrics[0].Line[0].End).To(Equal(ptr(int64(3000))))
|
||||
Expect(lyrics[0].Line[0].Value).To(Equal("Some lyrics here"))
|
||||
Expect(lyrics[0].Line[0].Cue).To(HaveLen(3))
|
||||
Expect(*lyrics[0].Line[0].Cue[0].Start).To(Equal(int64(1000)))
|
||||
Expect(lyrics[0].Line[0].Cue[0].Value).To(Equal("Some "))
|
||||
Expect(lyrics[0].Line[0].Cue[0].End).To(Equal(gg.P(int64(1500))))
|
||||
Expect(lyrics[0].Line[0].Cue[0].End).To(Equal(ptr(int64(1500))))
|
||||
Expect(lyrics[0].Line[0].Cue[0].ByteStart).To(Equal(0))
|
||||
Expect(lyrics[0].Line[0].Cue[0].ByteEnd).To(Equal(4))
|
||||
Expect(*lyrics[0].Line[0].Cue[1].Start).To(Equal(int64(1500)))
|
||||
Expect(lyrics[0].Line[0].Cue[1].Value).To(Equal("lyrics "))
|
||||
Expect(lyrics[0].Line[0].Cue[1].End).To(Equal(gg.P(int64(2000))))
|
||||
Expect(lyrics[0].Line[0].Cue[1].End).To(Equal(ptr(int64(2000))))
|
||||
Expect(lyrics[0].Line[0].Cue[1].ByteStart).To(Equal(5))
|
||||
Expect(lyrics[0].Line[0].Cue[1].ByteEnd).To(Equal(11))
|
||||
Expect(*lyrics[0].Line[0].Cue[2].Start).To(Equal(int64(2000)))
|
||||
Expect(lyrics[0].Line[0].Cue[2].Value).To(Equal("here"))
|
||||
Expect(lyrics[0].Line[0].Cue[2].End).To(Equal(gg.P(int64(3000))))
|
||||
Expect(lyrics[0].Line[0].Cue[2].End).To(Equal(ptr(int64(3000))))
|
||||
Expect(lyrics[0].Line[0].Cue[2].ByteStart).To(Equal(12))
|
||||
Expect(lyrics[0].Line[0].Cue[2].ByteEnd).To(Equal(15))
|
||||
|
||||
// Line 2: has inline markers
|
||||
Expect(lyrics[0].Line[1].Start).To(Equal(gg.P(int64(3000))))
|
||||
Expect(lyrics[0].Line[1].End).To(Equal(gg.P(int64(5000))))
|
||||
Expect(lyrics[0].Line[1].Start).To(Equal(ptr(int64(3000))))
|
||||
Expect(lyrics[0].Line[1].End).To(Equal(ptr(int64(5000))))
|
||||
Expect(lyrics[0].Line[1].Value).To(Equal("More words"))
|
||||
Expect(lyrics[0].Line[1].Cue).To(HaveLen(2))
|
||||
Expect(lyrics[0].Line[1].Cue[0].End).To(Equal(gg.P(int64(3500))))
|
||||
Expect(lyrics[0].Line[1].Cue[1].End).To(Equal(gg.P(int64(5000))))
|
||||
Expect(lyrics[0].Line[1].Cue[0].End).To(Equal(ptr(int64(3500))))
|
||||
Expect(lyrics[0].Line[1].Cue[1].End).To(Equal(ptr(int64(5000))))
|
||||
Expect(lyrics[0].Line[1].Cue[0].ByteStart).To(Equal(0))
|
||||
Expect(lyrics[0].Line[1].Cue[0].ByteEnd).To(Equal(4))
|
||||
Expect(lyrics[0].Line[1].Cue[1].ByteStart).To(Equal(5))
|
||||
Expect(lyrics[0].Line[1].Cue[1].ByteEnd).To(Equal(9))
|
||||
|
||||
// Line 3: plain line, no cues
|
||||
Expect(lyrics[0].Line[2].Start).To(Equal(gg.P(int64(5000))))
|
||||
Expect(lyrics[0].Line[2].Start).To(Equal(ptr(int64(5000))))
|
||||
Expect(lyrics[0].Line[2].Value).To(Equal("Plain line without inline markers"))
|
||||
Expect(lyrics[0].Line[2].Cue).To(BeNil())
|
||||
})
|
||||
@ -150,22 +150,22 @@ var _ = Describe("sources", func() {
|
||||
Expect(lyrics[0].Synced).To(BeTrue())
|
||||
Expect(lyrics[0].Line).To(HaveLen(2))
|
||||
|
||||
Expect(lyrics[0].Line[0].Start).To(Equal(gg.P(int64(1000))))
|
||||
Expect(lyrics[0].Line[0].End).To(Equal(gg.P(int64(3000))))
|
||||
Expect(lyrics[0].Line[0].Start).To(Equal(ptr(int64(1000))))
|
||||
Expect(lyrics[0].Line[0].End).To(Equal(ptr(int64(3000))))
|
||||
Expect(lyrics[0].Line[0].Value).To(Equal("Lead words"))
|
||||
Expect(lyrics[0].Line[0].Cue).To(HaveLen(2))
|
||||
Expect(*lyrics[0].Line[0].Cue[0].Start).To(Equal(int64(1000)))
|
||||
Expect(lyrics[0].Line[0].Cue[0].Value).To(Equal("Lead "))
|
||||
Expect(lyrics[0].Line[0].Cue[0].End).To(Equal(gg.P(int64(1500))))
|
||||
Expect(lyrics[0].Line[0].Cue[0].End).To(Equal(ptr(int64(1500))))
|
||||
Expect(lyrics[0].Line[0].Cue[0].ByteStart).To(Equal(0))
|
||||
Expect(lyrics[0].Line[0].Cue[0].ByteEnd).To(Equal(4))
|
||||
Expect(*lyrics[0].Line[0].Cue[1].Start).To(Equal(int64(1500)))
|
||||
Expect(lyrics[0].Line[0].Cue[1].Value).To(Equal("words"))
|
||||
Expect(lyrics[0].Line[0].Cue[1].End).To(Equal(gg.P(int64(3000))))
|
||||
Expect(lyrics[0].Line[0].Cue[1].End).To(Equal(ptr(int64(3000))))
|
||||
Expect(lyrics[0].Line[0].Cue[1].ByteStart).To(Equal(5))
|
||||
Expect(lyrics[0].Line[0].Cue[1].ByteEnd).To(Equal(9))
|
||||
|
||||
Expect(lyrics[0].Line[1].Start).To(Equal(gg.P(int64(3000))))
|
||||
Expect(lyrics[0].Line[1].Start).To(Equal(ptr(int64(3000))))
|
||||
Expect(lyrics[0].Line[1].Value).To(Equal("Fallback line"))
|
||||
Expect(lyrics[0].Line[1].Cue).To(BeNil())
|
||||
})
|
||||
@ -201,13 +201,13 @@ var _ = Describe("sources", func() {
|
||||
Lang: "xxx",
|
||||
Line: []model.Line{
|
||||
{
|
||||
Start: gg.P(int64(18800)),
|
||||
End: gg.P(int64(22800)),
|
||||
Start: ptr(int64(18800)),
|
||||
End: ptr(int64(22800)),
|
||||
Value: "We're from subtitles",
|
||||
},
|
||||
{
|
||||
Start: gg.P(int64(22801)),
|
||||
End: gg.P(int64(26000)),
|
||||
Start: ptr(int64(22801)),
|
||||
End: ptr(int64(26000)),
|
||||
Value: "Another subtitle line",
|
||||
},
|
||||
},
|
||||
@ -227,11 +227,11 @@ var _ = Describe("sources", func() {
|
||||
Lang: "eng",
|
||||
Line: []model.Line{
|
||||
{
|
||||
Start: gg.P(int64(18800)),
|
||||
Start: ptr(int64(18800)),
|
||||
Value: "We're no strangers to love",
|
||||
},
|
||||
{
|
||||
Start: gg.P(int64(22800)),
|
||||
Start: ptr(int64(22800)),
|
||||
Value: "You know the rules and so do I",
|
||||
},
|
||||
},
|
||||
@ -242,7 +242,7 @@ var _ = Describe("sources", func() {
|
||||
Lang: "por",
|
||||
Line: []model.Line{
|
||||
{
|
||||
Start: gg.P(int64(18800)),
|
||||
Start: ptr(int64(18800)),
|
||||
Value: "Nao somos estranhos ao amor",
|
||||
},
|
||||
},
|
||||
@ -294,7 +294,7 @@ var _ = Describe("sources", func() {
|
||||
Expect(lyrics[0].Kind).To(Equal("main"))
|
||||
Expect(lyrics[0].Synced).To(BeTrue())
|
||||
Expect(lyrics[0].Line).To(HaveLen(1))
|
||||
Expect(lyrics[0].Line[0].Start).To(Equal(gg.P(int64(0))))
|
||||
Expect(lyrics[0].Line[0].Start).To(Equal(ptr(int64(0))))
|
||||
Expect(lyrics[0].Line[0].Value).To(Equal("BOM test line"))
|
||||
})
|
||||
|
||||
@ -307,9 +307,9 @@ var _ = Describe("sources", func() {
|
||||
Expect(lyrics[0].Kind).To(Equal("main"))
|
||||
Expect(lyrics[0].Synced).To(BeTrue())
|
||||
Expect(lyrics[0].Line).To(HaveLen(2))
|
||||
Expect(lyrics[0].Line[0].Start).To(Equal(gg.P(int64(18800))))
|
||||
Expect(lyrics[0].Line[0].Start).To(Equal(ptr(int64(18800))))
|
||||
Expect(lyrics[0].Line[0].Value).To(Equal("UTF16 line one"))
|
||||
Expect(lyrics[0].Line[1].Start).To(Equal(gg.P(int64(22801))))
|
||||
Expect(lyrics[0].Line[1].Start).To(Equal(ptr(int64(22801))))
|
||||
Expect(lyrics[0].Line[1].Value).To(Equal("UTF16 line two"))
|
||||
})
|
||||
})
|
||||
|
||||
5
core/lyrics/test_helpers_test.go
Normal file
5
core/lyrics/test_helpers_test.go
Normal file
@ -0,0 +1,5 @@
|
||||
package lyrics
|
||||
|
||||
func ptr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
@ -2,7 +2,6 @@ package lyrics
|
||||
|
||||
import (
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/utils/gg"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
@ -31,15 +30,15 @@ var _ = Describe("parseTTML", func() {
|
||||
eng := list[0]
|
||||
Expect(eng.Lang).To(Equal("eng"))
|
||||
Expect(eng.Synced).To(BeTrue())
|
||||
Expect(eng.Line[0].Start).To(Equal(gg.P(int64(3000))))
|
||||
Expect(eng.Line[0].Start).To(Equal(ptr(int64(3000))))
|
||||
Expect(eng.Line[0].Value).To(Equal("Line one"))
|
||||
Expect(eng.Line[1].Start).To(Equal(gg.P(int64(4517))))
|
||||
Expect(eng.Line[1].Start).To(Equal(ptr(int64(4517))))
|
||||
Expect(eng.Line[1].Value).To(Equal("Line two\nwith break"))
|
||||
|
||||
By("parsing the Portuguese track")
|
||||
por := list[1]
|
||||
Expect(por.Lang).To(Equal("por"))
|
||||
Expect(por.Line[0].Start).To(Equal(gg.P(int64(4500))))
|
||||
Expect(por.Line[0].Start).To(Equal(ptr(int64(4500))))
|
||||
Expect(por.Line[0].Value).To(Equal("Linha"))
|
||||
})
|
||||
})
|
||||
@ -60,7 +59,7 @@ var _ = Describe("parseTTML", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(list).To(HaveLen(1))
|
||||
Expect(list[0].Line).To(HaveLen(1))
|
||||
Expect(list[0].Line[0].Start).To(Equal(gg.P(int64(1000))))
|
||||
Expect(list[0].Line[0].Start).To(Equal(ptr(int64(1000))))
|
||||
Expect(list[0].Line[0].Value).To(Equal("Keep me"))
|
||||
})
|
||||
})
|
||||
@ -82,9 +81,9 @@ var _ = Describe("parseTTML", func() {
|
||||
Expect(list).To(HaveLen(1))
|
||||
Expect(list[0].Lang).To(Equal("eng"))
|
||||
Expect(list[0].Line).To(HaveLen(2))
|
||||
Expect(list[0].Line[0].Start).To(Equal(gg.P(int64(16000))))
|
||||
Expect(list[0].Line[0].Start).To(Equal(ptr(int64(16000))))
|
||||
Expect(list[0].Line[0].Value).To(Equal("First line"))
|
||||
Expect(list[0].Line[1].Start).To(Equal(gg.P(int64(18000))))
|
||||
Expect(list[0].Line[1].Start).To(Equal(ptr(int64(18000))))
|
||||
Expect(list[0].Line[1].Value).To(Equal("Second line"))
|
||||
})
|
||||
})
|
||||
@ -105,9 +104,9 @@ var _ = Describe("parseTTML", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(list).To(HaveLen(1))
|
||||
Expect(list[0].Line).To(HaveLen(2))
|
||||
Expect(list[0].Line[0].Start).To(Equal(gg.P(int64(10170))))
|
||||
Expect(list[0].Line[0].Start).To(Equal(ptr(int64(10170))))
|
||||
Expect(list[0].Line[0].Value).To(Equal("First line"))
|
||||
Expect(list[0].Line[1].Start).To(Equal(gg.P(int64(13710))))
|
||||
Expect(list[0].Line[1].Start).To(Equal(ptr(int64(13710))))
|
||||
Expect(list[0].Line[1].Value).To(Equal("Second line"))
|
||||
})
|
||||
})
|
||||
@ -136,14 +135,14 @@ var _ = Describe("parseTTML", func() {
|
||||
Expect(list[0].Line).To(HaveLen(1))
|
||||
|
||||
line := list[0].Line[0]
|
||||
Expect(line.Start).To(Equal(gg.P(int64(1000))))
|
||||
Expect(line.Start).To(Equal(ptr(int64(1000))))
|
||||
Expect(line.Value).To(Equal("Hello\necho"))
|
||||
Expect(line.End).To(Equal(gg.P(int64(3000))))
|
||||
Expect(line.End).To(Equal(ptr(int64(3000))))
|
||||
Expect(line.Cue).To(HaveLen(3))
|
||||
|
||||
Expect(line.Cue[0]).To(Equal(model.Cue{Start: gg.P(int64(1000)), End: gg.P(int64(1400)), Value: "He", ByteStart: 0, ByteEnd: 1, AgentID: "main"}))
|
||||
Expect(line.Cue[1]).To(Equal(model.Cue{Start: gg.P(int64(1400)), End: gg.P(int64(1800)), Value: "llo", ByteStart: 2, ByteEnd: 4, AgentID: "main"}))
|
||||
Expect(line.Cue[2]).To(Equal(model.Cue{Start: gg.P(int64(2000)), End: gg.P(int64(2500)), Value: "echo", ByteStart: 6, ByteEnd: 9, AgentID: "__nd_bg__|main"}))
|
||||
Expect(line.Cue[0]).To(Equal(model.Cue{Start: ptr(int64(1000)), End: ptr(int64(1400)), Value: "He", ByteStart: 0, ByteEnd: 1, AgentID: "main"}))
|
||||
Expect(line.Cue[1]).To(Equal(model.Cue{Start: ptr(int64(1400)), End: ptr(int64(1800)), Value: "llo", ByteStart: 2, ByteEnd: 4, AgentID: "main"}))
|
||||
Expect(line.Cue[2]).To(Equal(model.Cue{Start: ptr(int64(2000)), End: ptr(int64(2500)), Value: "echo", ByteStart: 6, ByteEnd: 9, AgentID: "__nd_bg__|main"}))
|
||||
})
|
||||
|
||||
It("should parse named TTML agents into main, voice, and group roles", func() {
|
||||
@ -267,12 +266,12 @@ var _ = Describe("parseTTML", func() {
|
||||
Expect(list[0].Line).To(HaveLen(1))
|
||||
|
||||
line := list[0].Line[0]
|
||||
Expect(line.Start).To(Equal(gg.P(int64(43444))))
|
||||
Expect(line.Start).To(Equal(ptr(int64(43444))))
|
||||
Expect(line.Value).To(Equal("go\ngo"))
|
||||
Expect(line.End).To(Equal(gg.P(int64(45570))))
|
||||
Expect(line.End).To(Equal(ptr(int64(45570))))
|
||||
Expect(line.Cue).To(HaveLen(2))
|
||||
Expect(line.Cue[0]).To(Equal(model.Cue{Start: gg.P(int64(43444)), End: gg.P(int64(43716)), Value: "go", ByteStart: 0, ByteEnd: 1}))
|
||||
Expect(line.Cue[1]).To(Equal(model.Cue{Start: gg.P(int64(43716)), End: gg.P(int64(43887)), Value: "go", ByteStart: 3, ByteEnd: 4}))
|
||||
Expect(line.Cue[0]).To(Equal(model.Cue{Start: ptr(int64(43444)), End: ptr(int64(43716)), Value: "go", ByteStart: 0, ByteEnd: 1}))
|
||||
Expect(line.Cue[1]).To(Equal(model.Cue{Start: ptr(int64(43716)), End: ptr(int64(43887)), Value: "go", ByteStart: 3, ByteEnd: 4}))
|
||||
})
|
||||
})
|
||||
|
||||
@ -342,21 +341,21 @@ var _ = Describe("parseTTML", func() {
|
||||
Expect(translation.Kind).To(Equal("translation"))
|
||||
Expect(translation.Lang).To(Equal("es"))
|
||||
Expect(translation.Line).To(HaveLen(1))
|
||||
Expect(translation.Line[0].Start).To(Equal(gg.P(int64(1000))))
|
||||
Expect(translation.Line[0].Start).To(Equal(ptr(int64(1000))))
|
||||
Expect(translation.Line[0].Value).To(Equal("Hola"))
|
||||
Expect(translation.Line[0].End).To(Equal(gg.P(int64(1500))))
|
||||
Expect(translation.Line[0].End).To(Equal(ptr(int64(1500))))
|
||||
|
||||
By("checking the pronunciation track")
|
||||
pronunciation := list[2]
|
||||
Expect(pronunciation.Kind).To(Equal("pronunciation"))
|
||||
Expect(pronunciation.Lang).To(Equal("ja-latn"))
|
||||
Expect(pronunciation.Line).To(HaveLen(1))
|
||||
Expect(pronunciation.Line[0].Start).To(Equal(gg.P(int64(2000))))
|
||||
Expect(pronunciation.Line[0].Start).To(Equal(ptr(int64(2000))))
|
||||
Expect(pronunciation.Line[0].Value).To(Equal("konni"))
|
||||
Expect(pronunciation.Line[0].End).To(Equal(gg.P(int64(2600))))
|
||||
Expect(pronunciation.Line[0].End).To(Equal(ptr(int64(2600))))
|
||||
Expect(pronunciation.Line[0].Cue).To(HaveLen(2))
|
||||
Expect(pronunciation.Line[0].Cue[0]).To(Equal(model.Cue{Start: gg.P(int64(2000)), End: gg.P(int64(2300)), Value: "ko", ByteStart: 0, ByteEnd: 1}))
|
||||
Expect(pronunciation.Line[0].Cue[1]).To(Equal(model.Cue{Start: gg.P(int64(2300)), End: gg.P(int64(2600)), Value: "nni", ByteStart: 2, ByteEnd: 4}))
|
||||
Expect(pronunciation.Line[0].Cue[0]).To(Equal(model.Cue{Start: ptr(int64(2000)), End: ptr(int64(2300)), Value: "ko", ByteStart: 0, ByteEnd: 1}))
|
||||
Expect(pronunciation.Line[0].Cue[1]).To(Equal(model.Cue{Start: ptr(int64(2300)), End: ptr(int64(2600)), Value: "nni", ByteStart: 2, ByteEnd: 4}))
|
||||
})
|
||||
})
|
||||
|
||||
@ -396,12 +395,12 @@ var _ = Describe("parseTTML", func() {
|
||||
Expect(pronunciation.Line).To(HaveLen(1))
|
||||
|
||||
line := pronunciation.Line[0]
|
||||
Expect(line.Start).To(Equal(gg.P(int64(2747))))
|
||||
Expect(line.Start).To(Equal(ptr(int64(2747))))
|
||||
Expect(line.Value).To(Equal("I woke up"))
|
||||
Expect(line.Cue).To(HaveLen(3))
|
||||
Expect(line.Cue[0]).To(Equal(model.Cue{Start: gg.P(int64(2747)), End: gg.P(int64(3018)), Value: "I", ByteStart: 0, ByteEnd: 0}))
|
||||
Expect(line.Cue[1]).To(Equal(model.Cue{Start: gg.P(int64(3018)), End: gg.P(int64(3179)), Value: "woke", ByteStart: 2, ByteEnd: 5}))
|
||||
Expect(line.Cue[2]).To(Equal(model.Cue{Start: gg.P(int64(3179)), End: gg.P(int64(3582)), Value: "up", ByteStart: 7, ByteEnd: 8}))
|
||||
Expect(line.Cue[0]).To(Equal(model.Cue{Start: ptr(int64(2747)), End: ptr(int64(3018)), Value: "I", ByteStart: 0, ByteEnd: 0}))
|
||||
Expect(line.Cue[1]).To(Equal(model.Cue{Start: ptr(int64(3018)), End: ptr(int64(3179)), Value: "woke", ByteStart: 2, ByteEnd: 5}))
|
||||
Expect(line.Cue[2]).To(Equal(model.Cue{Start: ptr(int64(3179)), End: ptr(int64(3582)), Value: "up", ByteStart: 7, ByteEnd: 8}))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -136,7 +136,7 @@ var _ = Describe("ToMediaFile", func() {
|
||||
{
|
||||
Kind: "main",
|
||||
Lang: "eng",
|
||||
Line: []model.Line{{Start: P(int64(1000)), End: P(int64(2500)), Value: "Embedded TTML line"}},
|
||||
Line: []model.Line{{Start: ptr(int64(1000)), End: ptr(int64(2500)), Value: "Embedded TTML line"}},
|
||||
Synced: true,
|
||||
},
|
||||
}))
|
||||
@ -174,7 +174,7 @@ var _ = Describe("ToMediaFile", func() {
|
||||
Expect(actual[0].Kind).To(Equal("main"))
|
||||
Expect(actual[0].Lang).To(Equal("en"))
|
||||
Expect(actual[0].Line).To(Equal([]model.Line{
|
||||
{Start: P(int64(1000)), End: P(int64(2500)), Value: "Long embedded TTML line"},
|
||||
{Start: ptr(int64(1000)), End: ptr(int64(2500)), Value: "Long embedded TTML line"},
|
||||
}))
|
||||
})
|
||||
|
||||
@ -192,7 +192,7 @@ Estamos nas legendas`},
|
||||
{
|
||||
Lang: "por",
|
||||
Line: []model.Line{
|
||||
{Start: P(int64(18800)), End: P(int64(22800)), Value: "Estamos nas legendas"},
|
||||
{Start: ptr(int64(18800)), End: ptr(int64(22800)), Value: "Estamos nas legendas"},
|
||||
},
|
||||
Synced: true,
|
||||
},
|
||||
|
||||
5
model/metadata/test_helpers_test.go
Normal file
5
model/metadata/test_helpers_test.go
Normal file
@ -0,0 +1,5 @@
|
||||
package metadata_test
|
||||
|
||||
func ptr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user