Restore fast typed decoding for ordinary transcripts
This commit is contained in:
@@ -366,6 +366,34 @@ func TestSourceTranscriptUsesEffectiveMemberValues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceTranscriptCombinesOrdinaryAndAliasedMembers(t *testing.T) {
|
||||
id := "7"
|
||||
if strconv.IntSize == 64 {
|
||||
id = "9007199254740993"
|
||||
}
|
||||
wantID, _ := strconv.Atoi(id)
|
||||
segments := `[
|
||||
{"speaker":"A","text":"He said \"{hello, world}\".","id":SOURCE_ID,
|
||||
"extra":{"speaker":12,"TEXT":"metadata"}},
|
||||
{"speaker":17,"spea\u006ber":"B","text":"expected","TEXT":"other","categories":[]},
|
||||
{"speaker":"C","ſpeaker":"D","text":"last"}
|
||||
]`
|
||||
segments = strings.Replace(segments, "SOURCE_ID", id, 1)
|
||||
for _, raw := range []string{segments, `{"segments":` + segments + "}"} {
|
||||
transcript, err := ParseSourceTranscriptJSON([]byte(raw))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := transcript.Canonical().Segments
|
||||
if len(got) != 3 || got[0].Speaker != "A" || got[0].ID != wantID ||
|
||||
got[0].Text != `He said "{hello, world}".` ||
|
||||
got[1].Speaker != "B" || got[1].Text != "expected" || got[1].Categories == nil ||
|
||||
got[2].Speaker != "D" || got[2].Text != "last" {
|
||||
t.Fatalf("unexpected segments: %+v", got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTranscriptClonePreservesPresenceAndIndependence(t *testing.T) {
|
||||
original := &Transcript{Segments: []Segment{
|
||||
{ID: 40, Text: "original", Categories: []string{"keep"}},
|
||||
|
||||
Reference in New Issue
Block a user