feat: genasset 剧本管线——--only=scripts 草稿生成 + --import-scripts 校验注音回填
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidateScript_DecisionOK(t *testing.T) {
|
||||
lines := []scriptLine{
|
||||
{Speaker: "旁白", Text: "夜深了,城里静悄悄的。"},
|
||||
{Speaker: "小军师", Text: "城门关得紧紧的。"},
|
||||
{Speaker: "小军师", Text: "我们怎么才能悄悄进城呢?", Emotion: "think"},
|
||||
}
|
||||
if err := validateScript(lines, true, "小军师"); err != nil {
|
||||
t.Fatalf("合法决策剧本应通过: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateScript_FinalOK(t *testing.T) {
|
||||
lines := []scriptLine{
|
||||
{Speaker: "旁白", Text: "天亮了,城门缓缓打开。"},
|
||||
{Speaker: "小军师", Text: "我们成功了,真是太好了!"},
|
||||
{Speaker: "小军师", Text: "我们一起进城啦!", Emotion: "happy"},
|
||||
}
|
||||
if err := validateScript(lines, false, "小军师"); err != nil {
|
||||
t.Fatalf("合法终局剧本应通过: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateScript_TooFewLines(t *testing.T) {
|
||||
lines := []scriptLine{{Speaker: "旁白", Text: "夜深了,城里静悄悄的。"}}
|
||||
if err := validateScript(lines, true, "小军师"); err == nil {
|
||||
t.Fatal("不足 3 句应报错")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateScript_MissingQuestion(t *testing.T) {
|
||||
lines := []scriptLine{
|
||||
{Speaker: "旁白", Text: "夜深了,城里静悄悄的。"},
|
||||
{Speaker: "小军师", Text: "城门关得紧紧的。"},
|
||||
{Speaker: "小军师", Text: "我们悄悄等天亮吧。"},
|
||||
}
|
||||
if err := validateScript(lines, true, "小军师"); err == nil {
|
||||
t.Fatal("决策节点末句未提问应报错")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateScript_BadSpeaker(t *testing.T) {
|
||||
lines := []scriptLine{
|
||||
{Speaker: "旁白", Text: "夜深了,城里静悄悄的。"},
|
||||
{Speaker: "路人甲", Text: "城门关得紧紧的。"},
|
||||
{Speaker: "小军师", Text: "我们怎么才能悄悄进城呢?"},
|
||||
}
|
||||
if err := validateScript(lines, true, "小军师"); err == nil {
|
||||
t.Fatal("非法 speaker 应报错")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateScript_BadLength(t *testing.T) {
|
||||
lines := []scriptLine{
|
||||
{Speaker: "旁白", Text: "夜深了。"},
|
||||
{Speaker: "小军师", Text: "城门关得紧紧的。"},
|
||||
{Speaker: "小军师", Text: "我们怎么才能悄悄进城呢?"},
|
||||
}
|
||||
if err := validateScript(lines, true, "小军师"); err == nil {
|
||||
t.Fatal("台词不足 8 字应报错")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user