Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PathFragment: test Windows mixed separator #22343

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ public void testGetParentDirectoryWindows() {
public void testSegmentsCountWindows() {
assertThat(create("C:/foo").segmentCount()).isEqualTo(1);
assertThat(create("C:/").segmentCount()).isEqualTo(0);
// Mix usage of Windows and Unix separator is valid
assertThat(create("C:/foo\\bar").segmentCount()).isEqualTo(2);
assertThat(create("C:\\foo\\bar/baz").segmentCount()).isEqualTo(3);
}

@Test
Expand All @@ -185,6 +188,12 @@ public void testGetSegmentWindows() {
assertThat(create("C:/foo/bar").getSegment(1)).isEqualTo("bar");
assertThat(create("C:/foo/").getSegment(0)).isEqualTo("foo");
assertThat(create("C:/foo").getSegment(0)).isEqualTo("foo");
// Mix usage of Windows and Unix separator is valid
assertThat(create("C:/foo\\bar").getSegment(0)).isEqualTo("foo");
assertThat(create("C:/foo\\bar").getSegment(1)).isEqualTo("bar");
assertThat(create("C:\\foo\\bar/baz").getSegment(0)).isEqualTo("foo");
assertThat(create("C:\\foo\\bar/baz").getSegment(1)).isEqualTo("bar");
assertThat(create("C:\\foo\\bar/baz").getSegment(2)).isEqualTo("baz");
}

@Test
Expand All @@ -193,6 +202,9 @@ public void testBasenameWindows() throws Exception {
assertThat(create("C:/foo").getBaseName()).isEqualTo("foo");
// Never return the drive name as a basename.
assertThat(create("C:/").getBaseName()).isEmpty();
// Mix usage of Windows and Unix separator is valid
assertThat(create("C:/foo\\bar").getBaseName()).isEqualTo("bar");
assertThat(create("C:\\foo\\bar/baz").getBaseName()).isEqualTo("baz");
}

@Test
Expand Down
Loading