Ad
  • Default User Avatar

    Hello !
    I've tried this in Java, and all work has expected when I run my solution on Eclipse and with the "Run Tests" button of this site. But When I click "Submit" tests doesn't work. I haven't modified the tests. What's happen please ?

  • Default User Avatar

    When I pass tests on Eclipse with JUnit, this test doesn't works:

    assertEquals(
    ""NORTH", "SOUTH", "SOUTH", "EAST", "WEST", "NORTH", "WEST"",
    new String[] { "WEST" },
    DirReduction.dirReduc(new String[] { "NORTH", "SOUTH", "SOUTH",
    "EAST", "WEST", "NORTH", "WEST" }));

    But this works:

    boolean test1 = Arrays.deepEquals(
    new String[] { "WEST" },
    DirectionsReduction.reduce(new String[] { "NORTH", "SOUTH",
    "SOUTH", "EAST", "WEST", "NORTH", "WEST" }));

    assertEquals("First assertion", test1, true);

    Because two arrays of string in Java are equals if they conatins same objects, not equals objects

  • Default User Avatar

    Java JUnits tests has a error. Equals in Java do not work as expected with arrays:

    System.out.println(new String[] { "WEST" }.equals(
    new String[] { "WEST" }));
    --> FALSE

    System.out.println(Arrays.deepEquals(new String[] { "WEST" },
    new String[] { "WEST" }));
    --> TRUE