public void Q02Permutation() { var q = new Question02(); Assert.IsTrue(q.ArePermutations("", "")); Assert.IsTrue(q.ArePermutations("ab", "ba")); Assert.IsTrue(q.ArePermutations("dog", "god")); Assert.IsFalse(q.ArePermutations("ab", "bb")); Assert.IsFalse(q.ArePermutations("a", "")); }
public void Question02ShouldThrowArgumentException() { var linkedList = new LinkedList <int>(); linkedList.AppendToTail(1); linkedList.AppendToTail(2); linkedList.AppendToTail(3); linkedList.AppendToTail(4); linkedList.AppendToTail(5); Assert.Throws <ArgumentException>( () => (Question02 <int> .GetNthToLastElement(linkedList, 6)) ); }
public void Question02ShouldGetNthToLastElement() { var linkedList = new LinkedList <int>(); linkedList.AppendToTail(1); linkedList.AppendToTail(2); linkedList.AppendToTail(3); linkedList.AppendToTail(4); linkedList.AppendToTail(5); Node <int> expected = linkedList.Head.Next.Next.Next; // 4 Node <int> actual = Question02 <int> .GetNthToLastElement(linkedList, 2); Assert.Equal(expected, actual); }
public void Question02ShouldFindPalindromes() { string input = "Test! aabbaa ccc"; var expected = new List <string>(); int expectedSize = 2; string expected1 = " aabbaa "; string expected2 = "ccc"; expected.Add(expected1); expected.Add(expected2); List <string> actual = Question02.FindPalindromes(input); Assert.Equal(expectedSize, actual.Count); Assert.Contains(expected1, actual); Assert.Contains(expected2, actual); }
public void Question02ShouldReverseAString() { Assert.Equal("dcba", Question02.Reverse("abcd")); }