Пример #1
0
        public void TestCollapseSpace()
        {
            var result = CharHelper.CollapseWhitespaces("");

            Assert.AreEqual("", result);

            result = CharHelper.CollapseWhitespaces("test1");
            Assert.AreEqual("test1", result);

            result = CharHelper.CollapseWhitespaces("test1 ");
            Assert.AreEqual("test1 ", result);

            result = CharHelper.CollapseWhitespaces(" test1");
            Assert.AreEqual(" test1", result);

            result = CharHelper.CollapseWhitespaces(" test1  test2  ");
            Assert.AreEqual(" test1 test2 ", result);

            result = CharHelper.CollapseWhitespaces(" \n \f \r \t ");
            Assert.AreEqual(" ", result);

            result = CharHelper.CollapseWhitespaces("\n \f \r \t ");
            Assert.AreEqual(" ", result);

            result = CharHelper.CollapseWhitespaces("\ntest1\n test2\n ");
            Assert.AreEqual(" test1 test2 ", result);
        }