@Test public void concat_windows() { GoPathContext context = new GoPathContext('\\', ";", "C:\\Users\\paul\\go"); assertThat(context.concat("C:\\Users", "paul")).isEqualTo("C:\\Users\\paul"); assertThat(context.concat("C:\\Users\\", "paul")).isEqualTo("C:\\Users\\paul"); assertThat(context.concat("C:\\", "paul")).isEqualTo("C:\\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; }