public async Task TestNormalisationAsync(string input) { // var expectedCount = input.Count(p => !char.IsSurrogate(p) && p != '\r'); using (var charReader = new AsyncLACharIterator(new StringReader(input), Capacity)) { var i = 0; while (i < input.Length) { int expectedCurrent; int expectedLA; input.CurrentAndLA(ref i, out expectedCurrent, out expectedLA); Assert.That(await charReader.MoveNextAsync(), Is.EqualTo(expectedCurrent != AsyncLACharIterator.EOF), "Move next i={0}", i); var current = await charReader.CurrentAsync(); Assert.That(current, Is.EqualTo(expectedCurrent), "Current codepoint i={0} expected={1} is={2}", i, expectedCurrent.DisplayUTF8(), current.DisplayUTF8()); var la = await charReader.LookAheadAsync(); Assert.That(la, Is.EqualTo(expectedLA), "Lookahead codepoint i={0} expected={1} is={2}", i, expectedLA.DisplayUTF8(), la.DisplayUTF8()); } } }
public void TestUninitialised() { using (var charReader = new AsyncLACharIterator(new StringReader(""), Capacity)) { // ReSharper disable AccessToDisposedClosure Assert.That(async() => await charReader.CurrentAsync(), Throws.InvalidOperationException); // ReSharper restore AccessToDisposedClosure } }
public void TestUninitialised() { using (var charReader = new AsyncLACharIterator(new StringReader(""), Capacity)) { // ReSharper disable AccessToDisposedClosure Assert.That(async () => await charReader.CurrentAsync(), Throws.InvalidOperationException); // ReSharper restore AccessToDisposedClosure } }