Ad
  • Default User Avatar

    This seems effecient. I'll make amends to my code soon. I'm pretty new here so I wasn't aware that this could be done.

  • Default User Avatar

    First beta, didn't realize how the honor system works so thanks for letting me know.

    Regarding the unit tests, it would be nice if the different scenarios were each broken out into a separate test case. When your code fails, you just see that you failed one test, but its not clear why (did I forget to handle undefined? is it because of negative numbers? etc.)

    If you put associated groups of "assertEquals" into their own @Test methods, the console output to the members will be more informative. For example, you might have:

    public void testSlopes() {
      Slope s=new Slope();
      
      int[] array1 = {3,-20,5,8};
      int[] array2 = {1,-19,-2,-7};
      int[] array3 = {6,-12,15,-3};
      int[] array4 = {9,3,19,-17};
    
      assertEquals("14", s.slope(array1));
      assertEquals("-4", s.slope(array2));
      assertEquals("1", s.slope(array3));
      assertEquals("-2", s.slope(array4));
    }
    
    public void testZero() {
      Slope s=new Slope();
      
      int[] array1 = {12,-18,-15,-18};
      int[] array2 = {19,3,20,3};
    
      assertEquals("0", s.slope(array1));
      assertEquals("0", s.slope(array2));
    }
    
    public void testUndefined() {
      Slope s=new Slope();
      
      int[] array1 = {17,-3,17,8};
      int[] array2 = {15,-3,15,-3};
    
      assertEquals("undefined", s.slope(array1));
      assertEquals("undefined", s.slope(array2));
    }
    

    Thanks again for the kata!

  • Default User Avatar

    but why did you categorize it as an "issue?" My honor gets deducted by one everytime you do so.And could you elaborate a little more on what you mean by "they are all in a single test case, perhaps could split them into separate test cases." thank you :)

  • Default User Avatar

    Ah apologies, I see now that it does test multiple cases. It is misleading because they are all in a single test case, perhaps could split them into separate test cases.

    Agreed that the formatting is a very minor issue, just commenting. It is still important on a site focused on practicing code quality.

  • Default User Avatar

    "The initial code block is not formatted properly - brackets are misaligned." this also seems like a big non issue.

  • Default User Avatar

    I really have no idea what you're talking about. and there are test cases for undefined. could you elaborate a little more?

  • Default User Avatar

    The initial code block is not formatted properly - brackets are misaligned.

    The unit tests do not test for edge cases; at a minimum, should test for "undefined".