Example #1
0
        public void TestWordNextWithInt()
        {
            BreakIterator bi = GetWordInstance(CultureInfo.InvariantCulture);

            bi.SetText(TEXT);

            int temp;

            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(0, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(6, temp);


            temp = bi.Next(10);
            Console.WriteLine(temp);
            assertEquals(23, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(23, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(39, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(39, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(40, temp);
            temp = bi.Next(-8);     // Test going backward
            Console.WriteLine(temp);
            assertEquals(16, temp); // Magically, this is correct (from position 28 back 8 places) in Java, even though its start position is wrong
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(17, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(17, temp);


            temp = bi.Next(107); // Go past the last boundary
            Console.WriteLine(temp);
            assertEquals(-1, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(107, temp);
            temp = bi.Next(-107); // Go past the first boundary
            Console.WriteLine(temp);
            assertEquals(-1, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(0, temp);
        }
Example #2
0
        public void TestWordIteration()
        {
            BreakIterator bi = GetWordInstance(CultureInfo.InvariantCulture);

            bi.SetText(TEXT);

            int temp;

            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(0, temp);

            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(6, temp);

            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(6, temp);

            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(7, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(7, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(13, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(13, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(14, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(16, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(17, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(17, temp);

            temp = bi.Previous();
            Console.WriteLine(temp);
            assertEquals(16, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(16, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(17, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(17, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(18, temp);

            temp = bi.Last();
            Console.WriteLine(temp);
            assertEquals(107, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(107, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(-1, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(107, temp);
            temp = bi.Previous();
            Console.WriteLine(temp);
            assertEquals(106, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(106, temp);
            temp = bi.Previous();
            Console.WriteLine(temp);
            assertEquals(102, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(102, temp);
            temp = bi.Previous();
            Console.WriteLine(temp);
            assertEquals(101, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(101, temp);
        }
Example #3
0
        public void TestSentenceIteration()
        {
            BreakIterator bi = GetSentenceInstance(CultureInfo.InvariantCulture);

            bi.SetText(SENTENCE_TEXT);

            int temp;

            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(0, temp);

            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(108, temp);

            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(108, temp);

            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(221, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(221, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(290, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(290, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(324, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(344, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(364, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(364, temp);

            temp = bi.Previous();
            Console.WriteLine(temp);
            assertEquals(344, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(344, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(364, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(364, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(380, temp);

            temp = bi.First();
            Console.WriteLine(temp);
            assertEquals(0, temp);

            temp = bi.Last();
            Console.WriteLine(temp);
            assertEquals(400, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(400, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(-1, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(400, temp);
            temp = bi.Previous();
            Console.WriteLine(temp);
            assertEquals(380, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(380, temp);
            temp = bi.Previous();
            Console.WriteLine(temp);
            assertEquals(364, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(364, temp);
            temp = bi.Previous();
            Console.WriteLine(temp);
            assertEquals(344, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(344, temp);
        }
Example #4
0
        public void TestWordPreceding()
        {
            BreakIterator bi = GetWordInstance(CultureInfo.InvariantCulture);

            bi.SetText(TEXT);

            int temp;

            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(0, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(6, temp);


            temp = bi.Preceding(70);
            Console.WriteLine(temp);
            assertEquals(67, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(67, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(73, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(73, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(74, temp);
            temp = bi.Preceding(107); // Test the final boundary
            Console.WriteLine(temp);
            assertEquals(106, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(107, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(107, temp);

            temp = bi.Preceding(66); // Test exactly on a boundary position
            Console.WriteLine(temp);
            assertEquals(60, temp);
            temp = bi.Previous();
            Console.WriteLine(temp);
            assertEquals(59, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(59, temp);

            temp = bi.Preceding(0); // Test the first boundary
            Console.WriteLine(temp);
            assertEquals(-1, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(0, temp);
            temp = bi.Next();
            Console.WriteLine(temp);
            assertEquals(6, temp);
            temp = bi.Current;
            Console.WriteLine(temp);
            assertEquals(6, temp);
        }