public void MyAtoiTest6() { var input = "90000000000"; var expected = int.MaxValue; StringToInteger.MyAtoi(input).Should().Be(expected); }
public void MyAtoiTest4() { var input = "words and 987"; var expected = 0; StringToInteger.MyAtoi(input).Should().Be(expected); }
public void MyAtoiTest5() { var input = "-91283472332"; var expected = int.MinValue; StringToInteger.MyAtoi(input).Should().Be(expected); }
public void MyAtoiTest3() { var input = "4193 with words"; var expected = 4193; StringToInteger.MyAtoi(input).Should().Be(expected); }
public void MyAtoiTest2() { var input = " -42"; var expected = -42; StringToInteger.MyAtoi(input).Should().Be(expected); }
public void TestStringToInteger() { StringToInteger stringToInteger = new StringToInteger(); Assert.Equal(42, stringToInteger.MyAtoi("42")); Assert.Equal(-42, stringToInteger.MyAtoi(" -42")); Assert.Equal(4193, stringToInteger.MyAtoi("4193 with words")); Assert.Equal(0, stringToInteger.MyAtoi("words and 987")); Assert.Equal(-2147483648, stringToInteger.MyAtoi("-91283472332")); //Assert.Equal(3.14159, stringToInteger.MyAtoi("3.14159")); }
private static void StringToIntegerTest() { Console.WriteLine("\nReverse Integer question:"); string[] testStrings = new string[] { "42", " -42", "4193 with words", "words and 987", "-91283472332", "+1", "2147483648" }; StringToInteger stringToInteger = new StringToInteger(); foreach (string str in testStrings) { Console.WriteLine("{0} -> {1}", str, stringToInteger.MyAtoi(str)); } }
public void TestStringToInteger() { var r = StringToInteger.Atoi("123213123"); Assert.AreEqual(r, 123213123); r = StringToInteger.Atoi(" -123213123"); Assert.AreEqual(r, -123213123); r = StringToInteger.Atoi("asd 222"); Assert.AreEqual(r, 0); r = StringToInteger.Atoi(" 444 asadasdsa"); Assert.AreEqual(r, 444); r = StringToInteger.Atoi("111111111111111"); Assert.AreEqual(r, 0); }
public void TestName() { //Given var instance = new StringToInteger(); var s1 = "42"; var s2 = " -42"; var s3 = "4193 with words"; var s4 = "words and 987"; var s5 = "-91283472332"; //When //Then Assert.Equal(42, instance.MyAtoi(s1)); Assert.Equal(-42, instance.MyAtoi(s2)); Assert.Equal(4193, instance.MyAtoi(s3)); Assert.Equal(0, instance.MyAtoi(s4)); Assert.Equal(-2147483648, instance.MyAtoi(s5)); }
public void StringToIntegerTestMethod5() { int value = StringToInteger.MyAtoi("-91283472332"); Assert.AreEqual(-2147483648, value); }
public void StringToIntegerTestMethod4() { int value = StringToInteger.MyAtoi("words and 987"); Assert.AreEqual(0, value); }
public void StringToIntegerTestMethod3() { int value = StringToInteger.MyAtoi("4193 with words"); Assert.AreEqual(4193, value); }
void InternalTest(string str, int expected) { int actual = StringToInteger.MyAtoi(str); Assert.Equal <int>(expected, actual); }
static void Main(string[] args) { #region 1. Two Sum TwoSums twoSums = new TwoSums(new int[] { 2, 7, 11, 15 }, 18); twoSums.PrintExample(); #endregion #region 3. LongestSubstringWithoutRepeatingCharacters LongestSubstringWithoutRepeatingCharacters longestSubstringWithoutRepeating = new LongestSubstringWithoutRepeatingCharacters("abcdecb"); longestSubstringWithoutRepeating.PrintExample(); #endregion #region 7. Reverse Integer ReverseInteger reverseInteger = new ReverseInteger(-54321); reverseInteger.PrintExample(); #endregion #region 8. String to Integer (atoi) StringToInteger stringToInteger = new StringToInteger(" -42"); stringToInteger.PrintExample(); #endregion #region 9. Palindrome Number PalindromeNumber palindromeNumber = new PalindromeNumber(121); palindromeNumber.PrintExample(); #endregion #region 20. Valid Parentheses ValidParentheses validParentheses = new ValidParentheses("(){[]}"); validParentheses.PrintExample(); #endregion #region 26. Remove Duplicates from Sorted Array RemoveDuplicatesFromSortedArray removeDuplicatesFromSortedArray = new RemoveDuplicatesFromSortedArray(new [] { 1, 2, 3, 3, 4, 5, 5, 5, 5, 5, 5, 6 }); removeDuplicatesFromSortedArray.PrintExample(); #endregion #region 35. Search Insert Position SearchInsertPosition searchInsertPosition = new SearchInsertPosition(new [] { 1, 3, 5, 10 }, 9); searchInsertPosition.PrintExample(); #endregion #region 58. Length of Last Word LengthOfLastWord lengthOfLastWord = new LengthOfLastWord("Hello World"); lengthOfLastWord.PrintExample(); #endregion #region 104. Maximum Depth of Binary Tree #endregion #region 125. Valid Palindrome ValidPalindrome validPalindrome = new ValidPalindrome("A man, a plan, a canal: Panama"); validPalindrome.PrintExample(); #endregion #region 136. Single Number SingleNumber singleNumber = new SingleNumber(new [] { 2, 2, 3, 3, 1 }); singleNumber.PrintExample(); #endregion #region 150. Evaluate Reverse Polish Notation EvaluateReversePolishNotation evaluateReversePolishNotation = new EvaluateReversePolishNotation(new [] { "2", "1", "+", "3", "*" }); evaluateReversePolishNotation.PrintExample(); #endregion #region 155. Min Stack MinStack minStack = new MinStack(); minStack.PrintExample(); #endregion #region 167. Two Sum II - Input array is sorted TwoSumII twoSumII = new TwoSumII(new [] { 1, 2, 3, 7 }, 10); twoSumII.PrintExample(); #endregion #region 200. Number of Islands NumberOfIslands numberOfIslands = new NumberOfIslands(new char[, ] { { '1', '1', '0', '0', '0' }, { '1', '1', '0', '0', '0' }, { '0', '0', '1', '0', '0' }, { '0', '0', '0', '1', '1' } }); numberOfIslands.PrintExample(); #endregion #region 217. Contains Duplicate ContainsDuplicate containsDuplicate = new ContainsDuplicate(new [] { 1, 2, 3, 1 }); containsDuplicate.PrintExample(); #endregion #region 268. Missing Number MissingNumber missingNumber = new MissingNumber(new [] { 9, 6, 4, 2, 3, 5, 7, 0, 1 }); missingNumber.PrintExample(); #endregion #region 344. Reverse String ReverseString reverseString = new ReverseString("A man with a plan"); reverseString.PrintExample(); #endregion #region 387. First Unique Character in a String FirstUniqueCharacterInAString firstUniqueChar = new FirstUniqueCharacterInAString("loveleetcode"); firstUniqueChar.PrintExample(); #endregion #region 412. FizzBuzz FizzBuzz fizzBuzz = new FizzBuzz(15); fizzBuzz.PrintExample(); #endregion #region 485. Max Consecutive Ones MaxConsecutiveOnes maxConsecutiveOnes = new MaxConsecutiveOnes(new int[] { 1, 1, 0, 1, 1, 1 }); maxConsecutiveOnes.PrintExample(); #endregion #region 509. Fibonacci Number FibonacciNumber fibonacciNumber = new FibonacciNumber(10); fibonacciNumber.PrintExample(); #endregion #region 622. Design Circular Queue CircularQueue circularQueue = new CircularQueue(1); Console.WriteLine("622. Design Circular Queue"); Console.WriteLine($"Front() : {circularQueue.Front()}"); Console.WriteLine($"IsEmpty() : {circularQueue.IsEmpty()}"); circularQueue.EnQueue(1); Console.WriteLine($"EnQueue(1)"); Console.WriteLine($"IsEmpty() : {circularQueue.IsEmpty()}"); Console.WriteLine($"IsFull() : {circularQueue.IsFull()}\n"); #endregion #region 707. Design Linked List LinkedList linkedList = new LinkedList(new Node()); linkedList.AddAtTail(10); linkedList.AddAtTail(20); linkedList.PrintLinkedList(); #endregion #region 709. To Lower Case ToLowerCase toLowerCase = new ToLowerCase("LOVELY"); toLowerCase.PrintExample(); #endregion #region 739. Daily Temperatures DailyTemperatures dailyTemperatures = new DailyTemperatures(new [] { 89, 62, 70, 58, 47, 47, 46, 76, 100, 70 }); dailyTemperatures.PrintExample(); #endregion #region 747. Largest Number at Least Twice of Others LargestNumberAtLeastTwiceOfOthers largestNumberAtLeastTwiceOfOthers = new LargestNumberAtLeastTwiceOfOthers(new [] { 3, 6, 1, 0 }); largestNumberAtLeastTwiceOfOthers.PrintExample(); #endregion #region 771. Jewels and Stones string j = "aA", s = "aAAbbbb"; JewelsAndStones jewelsAndStones = new JewelsAndStones(j, s); jewelsAndStones.PrintExample(); #endregion #region 832. Flipping an Image int[][] flippingImageArray = new int[3][]; flippingImageArray[0] = new int[] { 1, 1, 0 }; flippingImageArray[1] = new int[] { 1, 0, 1 }; flippingImageArray[2] = new int[] { 0, 0, 0 }; FlippingAnImage flippingAnImage = new FlippingAnImage(flippingImageArray); flippingAnImage.PrintExample(); #endregion #region 917. Reverse Only Letters ReverseOnlyLetters reverseOnlyLetters = new ReverseOnlyLetters("Qedo1ct-eeLg=ntse-T!"); reverseOnlyLetters.PrintExample(); #endregion Console.ReadLine(); }
static void Main(string[] args) { StringToInteger OB = new StringToInteger(); OB.myFxn(); }
public void StringToIntegerTestMethod2() { int value = StringToInteger.MyAtoi(" -42"); Assert.AreEqual(-42, value); }
public void MyAtoiTest(string str, int expected) { var actual = new StringToInteger().MyAtoi(str); Assert.Equal(expected, actual); }
public StringToIntegerTests() { _testsVerifier = new TestsVerifier(); _objUnderTest = new StringToInteger(); }