예제 #1
0
        public void Test_previous()
        {
            StringCharacterEnumerator fixture = new StringCharacterEnumerator("fixture");

            assertEquals(false, fixture.MovePrevious());
            assertTrue(fixture.MoveNext());
            assertEquals('i', fixture.Current);
            assertTrue(fixture.MoveNext());
            assertEquals('x', fixture.Current);
            assertTrue(fixture.MoveNext());
            assertEquals('t', fixture.Current);
            assertTrue(fixture.MoveNext());
            assertEquals('u', fixture.Current);
            assertTrue(fixture.MoveNext());
            assertEquals('r', fixture.Current);
            assertTrue(fixture.MoveNext());
            assertEquals('e', fixture.Current);
            assertEquals(false, fixture.MoveNext());
            assertEquals(false, fixture.MoveNext());
            assertEquals(false, fixture.MoveNext());
            assertEquals(6, fixture.Index);
            //assertTrue(fixture.MovePrevious());
            assertEquals('e', fixture.Current);
            assertEquals(6, fixture.Index);
            assertTrue(fixture.MovePrevious());
            assertEquals('r', fixture.Current);
            assertEquals(5, fixture.Index);
            assertTrue(fixture.MovePrevious());
            assertEquals('u', fixture.Current);
            assertEquals(4, fixture.Index);
            assertTrue(fixture.MovePrevious());
            assertEquals('t', fixture.Current);
            assertEquals(3, fixture.Index);
            assertTrue(fixture.MovePrevious());
            assertEquals('x', fixture.Current);
            assertEquals(2, fixture.Index);
            assertTrue(fixture.MovePrevious());
            assertEquals('i', fixture.Current);
            assertEquals(1, fixture.Index);
            assertTrue(fixture.MovePrevious());
            assertEquals('f', fixture.Current);
            assertEquals(0, fixture.Index);
            assertEquals(false, fixture.MovePrevious());
            assertEquals(0, fixture.Index);

            StringCharacterEnumerator it1 =
                new StringCharacterEnumerator("testing", 2, 4, 4);

            assertTrue(it1.MovePrevious());
            assertEquals("Wrong previous char1", 't', it1.Current);
            assertTrue(it1.MovePrevious());
            assertEquals("Wrong previous char2", 's', it1.Current);
            assertTrue("Wrong previous char3",
                       it1.MovePrevious() == false);
            assertTrue("Wrong previous char4",
                       it1.MovePrevious() == false);
            assertEquals("Wrong index", 2, it1.Index);
            assertEquals("Wrong current char", 's', it1.Current);
        }
예제 #2
0
        public void Test_setIndexI()
        {
            StringCharacterEnumerator it1 = new StringCharacterEnumerator("testing", 2,
                                                                          4, 4);

            it1.Index = 2;
            assertEquals("Wrong result1", 's', it1.Current);
            assertTrue(it1.MoveNext());
            char result = it1.Current;

            assertTrue("Wrong next char: " + result, result == 't');
            try
            {
                it1.Index = 6;
                fail("Assert 3: No ArgumentOutOfRangeException");
            }
            catch (ArgumentOutOfRangeException)
            {
                // expected
            }

            assertFalse("Wrong result2", it1.TrySetIndex(6));
            //assertTrue("Wrong result2", it1.SetIndex(6) == CharacterIterator.Done);
            //assertTrue(it1.MovePrevious());
            assertEquals("Wrong previous char", 'n', it1.Current);
            assertTrue(it1.MovePrevious());
            assertEquals("Wrong previous char", 'i', it1.Current);
        }
예제 #3
0
        public void Test_last()
        {
            StringCharacterEnumerator it1 = new StringCharacterEnumerator("testing", 2,
                                                                          4, 3);

            assertTrue(it1.MoveLast());
            assertEquals("Wrong last char", 'n', it1.Current);
            assertTrue(it1.MovePrevious());
            assertEquals("Wrong previous char", 'i', it1.Current);
            it1 = new StringCharacterEnumerator("testing", 2, 0, 2);
            assertTrue("Not DONE", it1.MoveLast() == false);
        }