Skip to content

Commit 8675e27

Browse files
committed
patch #194
1 parent eafe765 commit 8675e27

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/CatLib.Core.Tests/Support/Util/StrTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,5 +384,16 @@ public void TestJoinList()
384384
Assert.AreEqual("hello/world/catlib", result[2]);
385385
Assert.AreEqual(3, result.Length);
386386
}
387+
388+
[TestMethod]
389+
public void TestJoinListChar()
390+
{
391+
var result = Str.JoinList(new[] { "hello", "world", "catlib" }, '@');
392+
393+
Assert.AreEqual("hello", result[0]);
394+
Assert.AreEqual("hello@world", result[1]);
395+
Assert.AreEqual("hello@world@catlib", result[2]);
396+
Assert.AreEqual(3, result.Length);
397+
}
387398
}
388399
}

src/CatLib.Core/Support/Util/Str.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,12 @@ public static string[] JoinList(string[] source, string separator = null)
587587
}
588588
return source;
589589
}
590+
591+
/// <inheritdoc cref="JoinList(string[], char)"/>
592+
public static string[] JoinList(string[] source, char separator)
593+
{
594+
return JoinList(source, separator.ToString());
595+
}
590596
}
591597
}
592598

0 commit comments

Comments
 (0)