import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.List; import java.util.Map; class SolutionTest { void doIt(char[][] s, Map<Character, List<Character>> map) { String[] x = Arrays.stream(s).map(String::new).map(i-> String.join(i, "\n" +i)).toArray(String[]::new); assertEquals(map, TrainsAndRailwaysv2.travel(s), Arrays.toString(x) + ", map"); } void notDoIt(char[][] s) { assertEquals(new java.util.HashMap<Character, List<Character>>(), TrainsAndRailwaysv2.travel(s)); } @Test void esclusivePass() { doIt(new char[][] {"A---------------1".toCharArray()}, Map.of('1', List.of('A'))); doIt(new char[][] {"A----------¡-----1".toCharArray()}, Map.of('1', List.of('A'))); doIt(new char[][] {"A-----------\\ -----------1".toCharArray(), " -------------/ ".toCharArray()}, Map.of('1', List.of('A'))); doIt(new char[][] {"A-------- 1".toCharArray(), "B---------------2".toCharArray()}, Map.of('2', List.of('B'))); doIt(new char[][] {"A----) 1".toCharArray(), "B-----------------2".toCharArray()}, Map.of('2', List.of('B'))); } @Test void esclusiveNotPass() { notDoIt(new char[][] {"A-------- 1".toCharArray()}); notDoIt(new char[][] {{}}); notDoIt(new char[][] {"A----) 1".toCharArray()}); notDoIt(new char[][] {"A----\\ ".toCharArray(), " --------1".toCharArray()}); notDoIt(new char[][] {"A---------------------".toCharArray(), " 1".toCharArray()}); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Map;
- class SolutionTest {
@Testvoid testSomething() {// assertEquals("expected", "actual");}- void doIt(char[][] s, Map<Character, List<Character>> map) {
- String[] x = Arrays.stream(s).map(String::new).map(i-> String.join(i, "\n" +i)).toArray(String[]::new);
- assertEquals(map, TrainsAndRailwaysv2.travel(s), Arrays.toString(x) + ", map");
- }
- void notDoIt(char[][] s) {
- assertEquals(new java.util.HashMap<Character, List<Character>>(), TrainsAndRailwaysv2.travel(s));
- }
- @Test
- void esclusivePass() {
- doIt(new char[][] {"A---------------1".toCharArray()}, Map.of('1', List.of('A')));
- doIt(new char[][] {"A----------¡-----1".toCharArray()}, Map.of('1', List.of('A')));
- doIt(new char[][] {"A-----------\\ -----------1".toCharArray(),
- " -------------/ ".toCharArray()}, Map.of('1', List.of('A')));
- doIt(new char[][] {"A-------- 1".toCharArray(), "B---------------2".toCharArray()}, Map.of('2', List.of('B')));
- doIt(new char[][] {"A----) 1".toCharArray(), "B-----------------2".toCharArray()}, Map.of('2', List.of('B')));
- }
- @Test
- void esclusiveNotPass() {
- notDoIt(new char[][] {"A-------- 1".toCharArray()});
- notDoIt(new char[][] {{}});
- notDoIt(new char[][] {"A----) 1".toCharArray()});
- notDoIt(new char[][] {"A----\\ ".toCharArray(),
- " --------1".toCharArray()});
- notDoIt(new char[][] {"A---------------------".toCharArray(),
- " 1".toCharArray()});
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.List; import java.util.Map; class SolutionTest { /* void doIt(char[][] s, Map<Character, List<Character>> map) { String[] x = Arrays.stream(s).map(String::new).map(i-> String.join(i, "\n" +i)).toArray(String[]::new); assertEquals(map, TrainsAndRailwaysv2.travel(s), Arrays.toString(x) + ", map"); } void notDoIt(char[][] s) { assertEquals(new java.util.HashMap<Character, List<Character>>(), TrainsAndRailwaysv2.travel(s)); } @Test void esclusivePass() { doIt(new char[][] {"A---------------1".toCharArray()}, Map.of('1', List.of('A'))); doIt(new char[][] {"A----------¡-----1".toCharArray()}, Map.of('1', List.of('A'))); doIt(new char[][] {"A-----------\\ -----------1".toCharArray(), " -------------/ ".toCharArray()}, Map.of('1', List.of('A'))); doIt(new char[][] {"A-------- 1".toCharArray(), "B---------------2".toCharArray()}, Map.of('2', List.of('B'))); doIt(new char[][] {"A----) 1".toCharArray(), "B-----------------2".toCharArray()}, Map.of('2', List.of('B'))); } @Test void esclusiveNotPass() { notDoIt(new char[][] {"A-------- 1".toCharArray()}); notDoIt(new char[][] {{}}); notDoIt(new char[][] {"A----) 1".toCharArray()}); notDoIt(new char[][] {"A----\\ ".toCharArray(), " --------1".toCharArray()}); notDoIt(new char[][] {"A---------------------".toCharArray(), " 1".toCharArray()}); } */ }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
// TODO: Replace examples and use TDD by writing your own tests- import java.util.Arrays;
- import java.util.List;
- import java.util.Map;
- class SolutionTest {
@Testvoid testSomething() {// assertEquals("expected", "actual");//Buenos días}- /*
- void doIt(char[][] s, Map<Character, List<Character>> map) {
- String[] x = Arrays.stream(s).map(String::new).map(i-> String.join(i, "\n" +i)).toArray(String[]::new);
- assertEquals(map, TrainsAndRailwaysv2.travel(s), Arrays.toString(x) + ", map");
- }
- void notDoIt(char[][] s) {
- assertEquals(new java.util.HashMap<Character, List<Character>>(), TrainsAndRailwaysv2.travel(s));
- }
- @Test
- void esclusivePass() {
- doIt(new char[][] {"A---------------1".toCharArray()}, Map.of('1', List.of('A')));
- doIt(new char[][] {"A----------¡-----1".toCharArray()}, Map.of('1', List.of('A')));
- doIt(new char[][] {"A-----------\\ -----------1".toCharArray(),
- " -------------/ ".toCharArray()}, Map.of('1', List.of('A')));
- doIt(new char[][] {"A-------- 1".toCharArray(), "B---------------2".toCharArray()}, Map.of('2', List.of('B')));
- doIt(new char[][] {"A----) 1".toCharArray(), "B-----------------2".toCharArray()}, Map.of('2', List.of('B')));
- }
- @Test
- void esclusiveNotPass() {
- notDoIt(new char[][] {"A-------- 1".toCharArray()});
- notDoIt(new char[][] {{}});
- notDoIt(new char[][] {"A----) 1".toCharArray()});
- notDoIt(new char[][] {"A----\\ ".toCharArray(),
- " --------1".toCharArray()});
- notDoIt(new char[][] {"A---------------------".toCharArray(),
- " 1".toCharArray()});
- }
- */
- }