import 'package:flutter_test/flutter_test.dart'; import 'package:kouyu_english/core/speech_compare.dart'; void main() { test('a matching transcript ignores case, punctuation and contractions', () { final result = compareSpoken( 'Sorry, please say that again. I like water.', 'sorry please say that again i like water', ); expect(result.matches, isTrue); expect(result.heardCount, result.total); expect( compareSpoken('I’m from Hong Kong.', 'I am from Hong Kong').matches, isTrue, ); expect( compareSpoken('It’s three o’clock.', "it's three o'clock").matches, isTrue, ); }); test('marks the words that were not heard, keeping word order', () { final result = compareSpoken('I like tea. Do you like tea?', 'I like tea'); expect(result.matches, isFalse); expect(result.missedWords, ['Do', 'you', 'like', 'tea?']); expect(result.close, isFalse); final extra = compareSpoken('I like water.', 'I like water very much'); expect(extra.heardCount, extra.total); expect(extra.extraWords, ['very', 'much']); expect(extra.matches, isFalse); }); test('digits and joined letters line up with the model sentence', () { expect( compareSpoken( 'My number is one-three-eight.', 'My number is 138', ).matches, isTrue, ); expect(compareSpoken('S H E N', 'Shen').matches, isTrue); expect(compareSpoken('S H E N', 'S H E M').missedWords, ['N']); }); }