Adding Strings and unit test
This commit is contained in:
69
BasicProgrammingUnitTest/BasicProgramming__STRINGS.cs
Normal file
69
BasicProgrammingUnitTest/BasicProgramming__STRINGS.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using static BasicProgramming.Program;
|
||||
|
||||
namespace BasicProgrammingUnitTest;
|
||||
|
||||
public class BasicProgramming__STRINGS
|
||||
{
|
||||
[Fact]
|
||||
public void AddSeperator_TEST()
|
||||
{
|
||||
Assert.Equal("A^B^C^D", AddSeparator("ABCD", "^"));
|
||||
Assert.Equal("c-h-o-c-o-l-a-t-e", AddSeparator("chocolate", "-"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsPalindrome_TEST()
|
||||
{
|
||||
Assert.True(IsPalindrome("eye"));
|
||||
Assert.False(IsPalindrome("home"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LengthOfAString_TEST()
|
||||
{
|
||||
Assert.Equal(8, LengthOfAString("computer"));
|
||||
Assert.Equal(9, LengthOfAString("ice cream"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StringInReverseOrder_TEST()
|
||||
{
|
||||
Assert.Equal("ytrewq", StringInReverseOrder("qwerty"));
|
||||
Assert.Equal("rk 39eo", StringInReverseOrder("oe93 kr"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NumberOfWords_TEST()
|
||||
{
|
||||
Assert.Equal(4, NumberOfWords("This is sample sentence"));
|
||||
Assert.Equal(1, NumberOfWords("OK"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RevertWordsOrder_TEST()
|
||||
{
|
||||
Assert.Equal("Doe. John", RevertWordsOrder("John Doe."));
|
||||
Assert.Equal("C B. A,", RevertWordsOrder("A, B. C"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HowManyOccurrences_TEST()
|
||||
{
|
||||
Assert.Equal(1, HowManyOccurrences("do it now", "do"));
|
||||
Assert.Equal(0, HowManyOccurrences("empty", "d"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SortCharactersDescending_TEST()
|
||||
{
|
||||
Assert.Equal(['t', 'p', 'o', 'o', 'o', 'o', 'n', 'm', 'i', 'e', 'a', 'a'], SortCharactersDescending("onomatopoeia"));
|
||||
Assert.Equal(['w', 's', 'o', 'o', 'j', 'h', 'f', 'f', '4', '2'], SortCharactersDescending("fohjwf42os"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CompressString_TEST()
|
||||
{
|
||||
Assert.Equal("k4t3r10", CompressString("kkkktttrrrrrrrrrr"));
|
||||
Assert.Equal("p153p371w3", CompressString("p555ppp7www"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user