Пример #1
0
    public void BreakCharacterGroupsIntoWords()
    {
        string input = "some text";
        StructList <WordInfo> result = TextUtil.BreakIntoWords(input.ToCharArray());

        WordInfo[] expected =
        {
            new WordInfo()
            {
                type      = WordType.Normal,
                charStart = 0,
                charEnd   = 4
            },
            new WordInfo()
            {
                type      = WordType.Whitespace,
                charStart = 4,
                charEnd   = 5
            },
            new WordInfo()
            {
                type      = WordType.Normal,
                charStart = 5,
                charEnd   = 9
            }
        };

        Assert.AreEqual(expected.Length, result.size);

        for (int i = 0; i < result.size; i++)
        {
            Assert.AreEqual(expected[i], result.array[i]);
        }
    }