From 9d9f843e041b7c325ccf416c1e035ece95e2055e Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Mon, 25 Mar 2024 08:38:27 +0100 Subject: [PATCH] add endsWith(String) tests --- .../marschall/memoryfilesystem/PathTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/com/github/marschall/memoryfilesystem/PathTests.java b/src/test/java/com/github/marschall/memoryfilesystem/PathTests.java index 3586dbe..420a9f9 100644 --- a/src/test/java/com/github/marschall/memoryfilesystem/PathTests.java +++ b/src/test/java/com/github/marschall/memoryfilesystem/PathTests.java @@ -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; @@ -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")); + } } }