Add tests for applyRelativePath method in StringUtils
Closes gh-35397 Signed-off-by: Park Sung Jun <junstin119@gmail.com>
This commit is contained in:
parent
746fc335c2
commit
1653ec3b44
|
@ -794,6 +794,25 @@ class StringUtilsTests {
|
||||||
assertThat(StringUtils.collectionToCommaDelimitedString(Collections.singletonList(null))).isEqualTo("null");
|
assertThat(StringUtils.collectionToCommaDelimitedString(Collections.singletonList(null))).isEqualTo("null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void applyRelativePath() {
|
||||||
|
// Basic combination
|
||||||
|
assertThat(StringUtils.applyRelativePath("mypath/myfile", "otherfile")).isEqualTo("mypath/otherfile");
|
||||||
|
// Relative path starts with slash
|
||||||
|
assertThat(StringUtils.applyRelativePath("mypath/myfile", "/otherfile")).isEqualTo("mypath/otherfile");
|
||||||
|
// Includes root path
|
||||||
|
assertThat(StringUtils.applyRelativePath("/mypath/myfile", "otherfile")).isEqualTo("/mypath/otherfile");
|
||||||
|
assertThat(StringUtils.applyRelativePath("/mypath/myfile", "/otherfile")).isEqualTo("/mypath/otherfile");
|
||||||
|
// When base path has no slash
|
||||||
|
assertThat(StringUtils.applyRelativePath("myfile", "otherfile")).isEqualTo("otherfile");
|
||||||
|
// Keep parent directory token as-is
|
||||||
|
assertThat(StringUtils.applyRelativePath("mypath/myfile", "../otherfile")).isEqualTo("mypath/../otherfile");
|
||||||
|
// Base path ends with slash
|
||||||
|
assertThat(StringUtils.applyRelativePath("mypath/", "otherfile")).isEqualTo("mypath/otherfile");
|
||||||
|
// Empty relative path
|
||||||
|
assertThat(StringUtils.applyRelativePath("mypath/myfile", "")).isEqualTo("mypath/");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void truncatePreconditions() {
|
void truncatePreconditions() {
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalArgumentException()
|
||||||
|
|
Loading…
Reference in New Issue