Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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 ?
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
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