From 5a154c8a69f9fb5e0f04320bf3208c0fe3a76b1d Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Sat, 11 Jan 2025 13:43:02 +0200 Subject: [PATCH] filename tests --- .../topchetoeu/j2s/common/TestFilename.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 common/src/test/java/me/topchetoeu/j2s/common/TestFilename.java diff --git a/common/src/test/java/me/topchetoeu/j2s/common/TestFilename.java b/common/src/test/java/me/topchetoeu/j2s/common/TestFilename.java new file mode 100644 index 0000000..0da76e0 --- /dev/null +++ b/common/src/test/java/me/topchetoeu/j2s/common/TestFilename.java @@ -0,0 +1,39 @@ +package me.topchetoeu.j2s.common; + +import org.junit.jupiter.api.Test; + +import me.topchetoeu.j2s.common.parsing.Filename; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class TestFilename { + @Test public void testShouldParseFilePath() { + var filename = Filename.parse("file://hello.world"); + assertEquals("file", filename.protocol); + assertEquals("hello.world", filename.path); + } + @Test public void testShouldParseNoProtocolFilename() { + var filename = Filename.parse("hello.world"); + assertEquals("file", filename.protocol); + assertEquals("hello.world", filename.path); + } + @Test public void testShouldParseAdditionalSlashFilename() { + var filename = Filename.parse("test:///hello.world"); + assertEquals("test", filename.protocol); + assertEquals("/hello.world", filename.path); + } + @Test public void testShouldParseOneSlashFilename() { + var filename = Filename.parse("test:/hello.world"); + assertEquals("file", filename.protocol); + assertEquals("test:/hello.world", filename.path); + } + @Test public void testShouldParseMatroshkaFilename() { + var a = Filename.parse("a://b://hello.world"); + assertEquals("a", a.protocol); + assertEquals("b://hello.world", a.path); + + var b = Filename.parse(a.path); + assertEquals("b", b.protocol); + assertEquals("hello.world", b.path); + } +}