tests/search_match_inference: add more cases
This commit is contained in:
@@ -191,4 +191,67 @@ void main() {
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
test('Infer match with no matches', () {
|
||||
final wordSearchResult = WordSearchResult(
|
||||
entryId: 0,
|
||||
score: 0,
|
||||
isCommon: false,
|
||||
jlptLevel: JlptLevel.none,
|
||||
kanjiInfo: {},
|
||||
readingInfo: {},
|
||||
japanese: [WordSearchRuby(base: '仮名', furigana: 'かな')],
|
||||
senses: [
|
||||
WordSearchSense(
|
||||
antonyms: [],
|
||||
dialects: [],
|
||||
englishDefinitions: ['kana'],
|
||||
fields: [],
|
||||
info: [],
|
||||
languageSource: [],
|
||||
misc: [],
|
||||
partsOfSpeech: [],
|
||||
restrictedToKanji: [],
|
||||
restrictedToReading: [],
|
||||
seeAlso: [],
|
||||
),
|
||||
],
|
||||
sources: WordSearchSources.empty(),
|
||||
);
|
||||
|
||||
wordSearchResult.inferMatchSpans('xyz');
|
||||
|
||||
expect(wordSearchResult.matchSpans, isEmpty);
|
||||
});
|
||||
|
||||
test('Infer multiple matches of same substring', () {
|
||||
final wordSearchResult = WordSearchResult(
|
||||
entryId: 0,
|
||||
score: 0,
|
||||
isCommon: false,
|
||||
jlptLevel: JlptLevel.none,
|
||||
kanjiInfo: {},
|
||||
readingInfo: {},
|
||||
japanese: [WordSearchRuby(base: 'ああ')],
|
||||
senses: [],
|
||||
sources: WordSearchSources.empty(),
|
||||
);
|
||||
|
||||
wordSearchResult.inferMatchSpans('あ');
|
||||
|
||||
expect(wordSearchResult.matchSpans, [
|
||||
WordSearchMatchSpan(
|
||||
spanType: WordSearchMatchSpanType.kanji,
|
||||
start: 0,
|
||||
end: 1,
|
||||
index: 0,
|
||||
),
|
||||
WordSearchMatchSpan(
|
||||
spanType: WordSearchMatchSpanType.kanji,
|
||||
start: 1,
|
||||
end: 2,
|
||||
index: 0,
|
||||
),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user