public void Iterator_GetText_Limit() { var bytes = Encoding.UTF8.GetBytes("01234567890123456789"); var iterator = new ByteInputIterator(bytes); Assert.IsTrue(Encoding.ASCII.GetBytes("0").SequenceEqual(iterator.Text(0, 0)), "Text unable to return first character."); Assert.IsTrue(Encoding.ASCII.GetBytes("9").SequenceEqual(iterator.Text(19, 19)), "Text unable to return last character."); Assert.IsTrue(Encoding.ASCII.GetBytes("01").SequenceEqual(iterator.Text(0, 1)), "Text unable to return specified start and end characters inclusive."); try { iterator.Text(19, 0); Assert.Fail("Start must be <= End"); } catch (IteratorUsageException e) { } }
public void Iterator_GetText_Limit() { var bytes = Encoding.UTF8.GetBytes("01234567890123456789"); var iterator = new ByteInputIterator(bytes); Assert.IsTrue(Encoding.ASCII.GetBytes("0").SequenceEqual(iterator.Text(0, 0)), "Text unable to return first character."); Assert.IsTrue(Encoding.ASCII.GetBytes("9").SequenceEqual(iterator.Text(19, 19)), "Text unable to return last character."); Assert.IsTrue(Encoding.ASCII.GetBytes("01").SequenceEqual(iterator.Text(0, 1)), "Text unable to return specified start and end characters inclusive."); try { iterator.Text(19, 0); Assert.Fail("Start must be <= End"); } catch (IteratorUsageException e) { } }
public void Iterator_Initialization() { var input = "01234567890123456789"; var bytes = Encoding.UTF8.GetBytes(input); var iterator = new ByteInputIterator(bytes); // tests that iterator begins at zero based index Assert.IsTrue(iterator.Index == 0); Assert.IsTrue(iterator.Length == 20); Assert.IsTrue(iterator.Current() == '0'); Assert.IsTrue(iterator.Next() == '1'); Assert.IsTrue(iterator.Previous() == '0'); Assert.IsTrue(bytes.SequenceEqual(iterator.Text(0, 19)), "Text unable to return complete input."); }
public void Iterator_Initialization() { var input = "01234567890123456789"; var bytes = Encoding.UTF8.GetBytes(input); var iterator = new ByteInputIterator(bytes); // tests that iterator begins at zero based index Assert.IsTrue(iterator.Index == 0); Assert.IsTrue(iterator.Length == 20); Assert.IsTrue(iterator.Current() == '0'); Assert.IsTrue(iterator.Next() == '1'); Assert.IsTrue(iterator.Previous() == '0'); Assert.IsTrue(bytes.SequenceEqual(iterator.Text(0, 19)), "Text unable to return complete input."); }