@Test public void concat_linux() { GoPathContext context = new GoPathContext('/', ":", "/home/paul/go"); assertThat(context.concat("/home", "paul")).isEqualTo("/home/paul"); assertThat(context.concat("/home/", "paul")).isEqualTo("/home/paul"); assertThat(context.concat("/", "paul")).isEqualTo("/paul"); assertThat(context.concat("", "paul")).isEqualTo("paul"); }
String concat(String parentPath, String childPath) { if (parentPath.isEmpty() || parentPath.charAt(parentPath.length() - 1) == fileSeparator) { return parentPath + childPath; } return parentPath + fileSeparator + childPath; }
GoPathContext { String concat(String parentPath, String childPath) { if (parentPath.isEmpty() || parentPath.charAt(parentPath.length() - 1) == fileSeparator) { return parentPath + childPath; } return parentPath + fileSeparator + childPath; } }
GoPathContext { String concat(String parentPath, String childPath) { if (parentPath.isEmpty() || parentPath.charAt(parentPath.length() - 1) == fileSeparator) { return parentPath + childPath; } return parentPath + fileSeparator + childPath; } GoPathContext(char fileSeparator, String pathSeparator, @Nullable String goPath); }
GoPathContext { String concat(String parentPath, String childPath) { if (parentPath.isEmpty() || parentPath.charAt(parentPath.length() - 1) == fileSeparator) { return parentPath + childPath; } return parentPath + fileSeparator + childPath; } GoPathContext(char fileSeparator, String pathSeparator, @Nullable String goPath); String resolve(String filePath); }
GoPathContext { String concat(String parentPath, String childPath) { if (parentPath.isEmpty() || parentPath.charAt(parentPath.length() - 1) == fileSeparator) { return parentPath + childPath; } return parentPath + fileSeparator + childPath; } GoPathContext(char fileSeparator, String pathSeparator, @Nullable String goPath); String resolve(String filePath); static final GoPathContext DEFAULT; }