Falcon.SugarApi/Falcon.SugarApi.Test/StringExtendTest.cs

35 lines
1.0 KiB
C#
Raw Normal View History

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Falcon.SugarApi;
namespace Falcon.SugarApi.Test
{
/// <summary>
/// 字符串扩展方法测试
/// </summary>
[TestClass]
public class StringExtendTest
{
[TestMethod]
public void TestSplit() {
var str = $"a,b.c;de。fg";
var strArr = str.SplitStr();
Assert.AreEqual(7, strArr.Length, "分割后长度应该为7");
str = "a,,, ,b ,c c,";
strArr = str.SplitStr();
Assert.AreEqual(3, strArr.Length, "分割后长度应该为3");
Assert.AreEqual("a", strArr[0]);
Assert.AreEqual("b", strArr[1]);
Assert.AreEqual("c c", strArr[2]);
str = null;
strArr = str.SplitStr();
Assert.IsNotNull(strArr);
Assert.AreEqual(0, strArr.Length);
}
}
}