public void SingleWordTest() { var str = "Hello"; var boundaries = WordBoundaryAlgorithm.FindWordBoundaries(new Utf32Buffer(str).AsSlice()).ToList(); Assert.Single(boundaries); Assert.Equal(0, boundaries[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]); }
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]); }
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]); }
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); }
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())); }