Esempio n. 1
0
        public void SingleWordTest()
        {
            var str        = "Hello";
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(new Utf32Buffer(str).AsSlice()).ToList();

            Assert.Single(boundaries);
            Assert.Equal(0, boundaries[0]);
        }
Esempio n. 2
0
        public void CombinedLettersAndDigits()
        {
            var str        = "Hello99 World";
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(new Utf32Buffer(str).AsSlice()).ToList();

            Assert.Equal(2, boundaries.Count);
            Assert.Equal(0, boundaries[0]);
            Assert.Equal(8, boundaries[1]);
        }
Esempio n. 3
0
        public void TwoWordTest()
        {
            var str        = "Hello World";
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(new Utf32Buffer(str).AsSlice()).ToList();

            Assert.Equal(2, boundaries.Count);
            Assert.Equal(0, boundaries[0]);
            Assert.Equal(6, boundaries[1]);
        }
Esempio n. 4
0
        public void Punctuation2()
        {
            var str        = "Hello () World";
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(new Utf32Buffer(str).AsSlice()).ToList();

            Assert.Equal(3, boundaries.Count);
            Assert.Equal(0, boundaries[0]);
            Assert.Equal(6, boundaries[1]);
            Assert.Equal(9, boundaries[2]);
        }
Esempio n. 5
0
        public void TestIsWordBoundary()
        {
            var str = new Utf32Buffer("Hello () World").AsSlice();

            // Get the boundaries (assuming FindWordBoundaries is correct)
            var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(str).ToList();

            var boundaries2 = new List <int>();

            for (int i = 0; i < str.Length; i++)
            {
                if (WordBoundaryAlgorithm.IsWordBoundary(str.SubSlice(0, i), str.SubSlice(i, str.Length - i)))
                {
                    boundaries2.Add(i);
                }
            }

            Assert.Equal(boundaries, boundaries2);
        }
Esempio n. 6
0
 public bool ShouldAppend(StyledText text)
 {
     // If this is a word boundary then don't extend this unit
     return(!WordBoundaryAlgorithm.IsWordBoundary(_textBlock.CodePoints.SubSlice(0, _offset + _length), text.CodePoints.AsSlice()));
 }