summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Simmons (Tomboyo) <tomasimmons@gmail.com>2018-09-07 21:44:20 -0400
committerTom Simmons (Tomboyo) <tomasimmons@gmail.com>2018-09-07 21:44:20 -0400
commit01e2f3781c58a3033b41519229cb2049cb845d82 (patch)
tree5d95291765d79b4b7565a4649dc8ee96d878c1f9 /src/test
parent836017e17fcb4c434db64730e6f2b3fa9a8b2f55 (diff)
downloadjava-language-server-01e2f3781c58a3033b41519229cb2049cb845d82.zip
Check for drive-letter prefixed paths
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/javacs/UrlsTest.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/java/org/javacs/UrlsTest.java b/src/test/java/org/javacs/UrlsTest.java
new file mode 100644
index 0000000..8ede698
--- /dev/null
+++ b/src/test/java/org/javacs/UrlsTest.java
@@ -0,0 +1,46 @@
+package org.javacs;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import java.net.URL;
+import org.junit.Test;
+
+public class UrlsTest {
+
+ @Test
+ public void of_whenPathStartsWithSlash() throws Exception {
+ URL actual = Urls.of("/a/b/c");
+ assertEquals("file", actual.getProtocol());
+ assertEquals("/a/b/c", actual.getPath());
+ }
+
+ @Test
+ public void of_whenPathStartsWithProtocol() throws Exception {
+ URL actual = Urls.of("file:///a/b/c");
+ assertEquals("file", actual.getProtocol());
+ assertEquals("/a/b/c", actual.getPath());
+ }
+
+ @Test
+ public void of_whenPathStartsWithDriveLetter() throws Exception {
+ URL actual = Urls.of("c:/a/b/c");
+ assertEquals("file", actual.getProtocol());
+ }
+
+ @Test
+ public void isSystemPath_whenPathStartsWithSlash() {
+ assertTrue(Urls.isSystemPath("/a/b/c"));
+ }
+
+ @Test
+ public void isSystemPath_whenPathStartsWithDriveLetter() {
+ assertTrue(Urls.isSystemPath("c:/a/b/c"));
+ }
+
+ @Test
+ public void isSystemPath_whenPathStartsWithProtocol() {
+ assertFalse(Urls.isSystemPath("file://a/b/c"));
+ }
+} \ No newline at end of file