Skip to content

Commit

Permalink
add endsWith(String) tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marschall committed Mar 25, 2024
1 parent adb8a2f commit 9d9f843
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/test/java/com/github/marschall/memoryfilesystem/PathTests.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.github.marschall.memoryfilesystem;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.nio.file.FileSystem;
Expand Down Expand Up @@ -35,7 +37,19 @@ void subPath() throws IOException {
e = assertThrows(IllegalArgumentException.class, () -> absolutePath.subpath(2, 1));
assertEquals("beginIndex must be smaller than 2 but was 2", e.getMessage());
}
}

@Test
void endsWithString() throws IOException {
try (FileSystem fileSystem = this.extension.getFileSystem()) {
Path absolutePath = fileSystem.getPath("/parent/child.txt");
assertTrue(absolutePath.endsWith("/parent/child.txt"));
assertTrue(absolutePath.endsWith("parent/child.txt"));
assertTrue(absolutePath.endsWith("child.txt"));
assertTrue(absolutePath.endsWith("child.txt/"));
assertFalse(absolutePath.endsWith("/child.txt"));
assertFalse(absolutePath.endsWith("txt"));
}
}

}

0 comments on commit 9d9f843

Please sign in to comment.