none
Test cases RRS feed

  • Question

  • Hello,

    var numbers = new[] { 5, 7, 5, 3, 6, 7, 9 };

                var sorted = Sort(numbers);
                var maxes = FindMax(numbers, 2);

    For the code above, do the following test cases look sufficient please?Or am i missing on any other test case here?

                return sorted.First() == 3
                       && sorted.Last() == 9
                       && FindMax(numbers) == 9
                       && maxes[0] == 9
                       && maxes[1] == 7;

     Thanks.


    • Edited by ANi2000 Sunday, April 15, 2018 2:52 PM
    Friday, May 12, 2017 12:57 AM

All replies

  • You may want to add a second test case where there is two 9 in the array, and see if the function will return both "9" for the FindMax() function.

    Also, try test FindMax() with second parameter larger then length of numbers, or try pass empty array to both functions to see if the handling is what you expected.

    Friday, May 12, 2017 1:05 AM
    Answerer
  • Hi ANi200,

    Thank you for posting here.

    For your question, does the Sort() or FindMax() defined by yourself?

    Or you could use Array.Sort() method to sort the elements. Enumerable.Max() method to maximum value.

    For two methods, you could get it easier.

    int[] numbers = { 5, 7, 5, 3, 6, 7, 9 };
                Array.Sort(numbers);
                int i = numbers.Max();

    I hope this would be helpful.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 12, 2017 8:06 AM
    Moderator