#include #include "transcript.h" // 输出解析:Qwen3-ASR 的原始输出形如 "language English正文" class TstTranscript : public QObject { Q_OBJECT private slots: void splitsLanguageAndText() { const auto r = lc::parseAsrOutput("language EnglishHe hoped there would be stew."); QCOMPARE(QString::fromStdString(r.language), QString("English")); QCOMPARE(QString::fromStdString(r.text), QString("He hoped there would be stew.")); } void handlesChinese() { const auto r = lc::parseAsrOutput("language Chinese不排除购房者可以在互联网上下单。"); QCOMPARE(QString::fromStdString(r.language), QString("Chinese")); QCOMPARE(QString::fromStdString(r.text), QString("不排除购房者可以在互联网上下单。")); } void withoutMarkerKeepsWholeText() { const auto r = lc::parseAsrOutput(" just text "); QVERIFY(r.language.empty()); QCOMPARE(QString::fromStdString(r.text), QString("just text")); } void trimsSurroundingWhitespaceOfBody() { const auto r = lc::parseAsrOutput("language English hi there "); QCOMPARE(QString::fromStdString(r.text), QString("hi there")); } void displayNameMapping() { QCOMPARE(QString::fromStdString(lc::languageDisplayName("English")), QString("英语")); QCOMPARE(QString::fromStdString(lc::languageDisplayName("Chinese")), QString("中文")); // 未收录的语言原样返回 QCOMPARE(QString::fromStdString(lc::languageDisplayName("Klingon")), QString("Klingon")); QVERIFY(lc::languageDisplayName("").empty()); } }; QTEST_MAIN(TstTranscript) #include "tst_transcript.moc"