2022-03-22 16:53:24 +08:00
|
|
|
|
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
|
|
|
|
|
{
|
2022-03-30 17:08:07 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字符串扩展方法测试
|
|
|
|
|
/// </summary>
|
2022-03-22 16:53:24 +08:00
|
|
|
|
[TestClass]
|
|
|
|
|
public class StringExtendTest
|
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void TestSplit() {
|
|
|
|
|
var str = $"a,b.c;d,e。f;g";
|
|
|
|
|
var strArr = str.SplitStr();
|
|
|
|
|
Assert.AreEqual(7, strArr.Length, "分割后长度应该为7");
|
2022-03-29 16:14:07 +08:00
|
|
|
|
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]);
|
2022-03-22 16:53:24 +08:00
|
|
|
|
str = null;
|
|
|
|
|
strArr = str.SplitStr();
|
|
|
|
|
Assert.IsNotNull(strArr);
|
|
|
|
|
Assert.AreEqual(0, strArr.Length);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|