feat(card): the card browser finds and sorts words of any language as typed
Search folded case and katakana only, for Japanese. It now also leaves out accents, tone marks and umlauts (strasse finds Straße, maedchen and madchen Mädchen, σπιτι σπίτι, xue xi xué xí), and A–Z sorts by the same bare letters, so Ärger stands among the a's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
e93f37ce68
commit
87bebd1953
1 changed files with 84 additions and 4 deletions
|
|
@ -0,0 +1,29 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/card/model/card_browser.dart';
|
||||
|
||||
void main() {
|
||||
test('a search finds words of any language as typed on any keyboard: '
|
||||
'without accents, tone marks or umlauts, ß as ss, kana by romaji', () {
|
||||
bool finds(String text, String query) =>
|
||||
matchesQuery(searchFolded(text), query);
|
||||
|
||||
expect(finds('Straße', 'strasse'), isTrue);
|
||||
expect(finds('Mädchen', 'madchen'), isTrue);
|
||||
expect(finds('Mädchen', 'maedchen'), isTrue);
|
||||
expect(finds('το σπίτι', 'σπιτι'), isTrue);
|
||||
expect(finds('ο δρόμος', 'δρομος'), isTrue);
|
||||
expect(finds('xué xí', 'xue xi'), isTrue);
|
||||
expect(finds('nǚ ér', 'nu er'), isTrue);
|
||||
expect(finds('café', 'CAFE'), isTrue);
|
||||
expect(finds('たべる', 'taberu'), isTrue);
|
||||
expect(finds('テレビ', 'てれび'), isTrue);
|
||||
expect(finds('Haus', 'maus'), isFalse);
|
||||
});
|
||||
|
||||
test('A–Z compares letters as their bare ones: Ärger among the a, xué '
|
||||
'beside xue', () {
|
||||
expect(searchFolded('Ärger'), 'arger');
|
||||
expect(searchFolded('xué'), 'xue');
|
||||
expect(searchFolded('ὁδός'), 'οδοσ');
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue