示例#1
0
        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 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());
                }
            }
        }
示例#3
0
 public async Task TestSupportResetting(string input)
 {
     using (var charReader = new AsyncLACharIterator(new StringReader(input), Capacity))
     {
         if (charReader.SupportsResetting)
         {
             var isEmpty = true;
             while (await charReader.MoveNextAsync())
             {
                 isEmpty = false;
             }
             charReader.Reset();
             Assert.That(charReader.MoveNextAsync(), Is.EqualTo(isEmpty), "Has element after resetting is not empty");
         }
         else
         {
             Assert.That(charReader.Reset, Throws.InvalidOperationException);
         }
     }
 }
 public async Task TestSupportResetting(string input)
 {
     using (var charReader = new AsyncLACharIterator(new StringReader(input), Capacity))
     {
         if (charReader.SupportsResetting)
         {
             var isEmpty = true;
             while (await charReader.MoveNextAsync())
             {
                 isEmpty = false;
             }
             charReader.Reset();
             Assert.That(charReader.MoveNextAsync(), Is.EqualTo(isEmpty), "Has element after resetting is not empty");
         }
         else
         {
             Assert.That(charReader.Reset, Throws.InvalidOperationException);
         }
     }
 }