UriUtilsTest: clean
This commit is contained in:
parent
fd5471b615
commit
a76e84cf1d
|
@ -45,39 +45,27 @@ class UriUtilsTest {
|
||||||
fun joinUrls() {
|
fun joinUrls() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"gemini://dece.space/some-file.gmi",
|
"gemini://dece.space/some-file.gmi",
|
||||||
dev.lowrespalmtree.comet.utils.joinUrls("gemini://dece.space/", "some-file.gmi")
|
joinUrls("gemini://dece.space/", "some-file.gmi").toString()
|
||||||
.toString()
|
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"gemini://dece.space/some-file.gmi",
|
"gemini://dece.space/some-file.gmi",
|
||||||
dev.lowrespalmtree.comet.utils.joinUrls("gemini://dece.space/", "./some-file.gmi")
|
joinUrls("gemini://dece.space/", "./some-file.gmi").toString()
|
||||||
.toString()
|
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"gemini://dece.space/some-file.gmi",
|
"gemini://dece.space/some-file.gmi",
|
||||||
dev.lowrespalmtree.comet.utils.joinUrls("gemini://dece.space/dir1", "/some-file.gmi")
|
joinUrls("gemini://dece.space/dir1", "/some-file.gmi").toString()
|
||||||
.toString()
|
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"gemini://dece.space/dir1/other-file.gmi",
|
"gemini://dece.space/dir1/other-file.gmi",
|
||||||
dev.lowrespalmtree.comet.utils.joinUrls(
|
joinUrls("gemini://dece.space/dir1/file.gmi", "other-file.gmi").toString()
|
||||||
"gemini://dece.space/dir1/file.gmi",
|
|
||||||
"other-file.gmi"
|
|
||||||
).toString()
|
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"gemini://dece.space/top-level.gmi",
|
"gemini://dece.space/top-level.gmi",
|
||||||
dev.lowrespalmtree.comet.utils.joinUrls(
|
joinUrls("gemini://dece.space/dir1/file.gmi", "../top-level.gmi").toString()
|
||||||
"gemini://dece.space/dir1/file.gmi",
|
|
||||||
"../top-level.gmi"
|
|
||||||
).toString()
|
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"s://hard/test/b/d/a.gmi",
|
"s://hard/test/b/d/a.gmi",
|
||||||
dev.lowrespalmtree.comet.utils.joinUrls(
|
joinUrls("s://hard/dir/a", "./../test/b/c/../d/e/f/../.././a.gmi").toString()
|
||||||
"s://hard/dir/a",
|
|
||||||
"./../test/b/c/../d/e/f/../.././a.gmi"
|
|
||||||
).toString()
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,28 +81,28 @@ class UriUtilsTest {
|
||||||
Pair("mid/content=5/../6", "mid/6"),
|
Pair("mid/content=5/../6", "mid/6"),
|
||||||
Pair("../../../../g", "g")
|
Pair("../../../../g", "g")
|
||||||
).forEach { (path, expected) ->
|
).forEach { (path, expected) ->
|
||||||
assertEquals(expected, dev.lowrespalmtree.comet.utils.removeDotSegments(path))
|
assertEquals(expected, removeDotSegments(path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun removeLastSegment() {
|
fun removeLastSegment() {
|
||||||
assertEquals("", dev.lowrespalmtree.comet.utils.removeLastSegment(""))
|
assertEquals("", removeLastSegment(""))
|
||||||
assertEquals("", dev.lowrespalmtree.comet.utils.removeLastSegment("/"))
|
assertEquals("", removeLastSegment("/"))
|
||||||
assertEquals("", dev.lowrespalmtree.comet.utils.removeLastSegment("/a"))
|
assertEquals("", removeLastSegment("/a"))
|
||||||
assertEquals("/a", dev.lowrespalmtree.comet.utils.removeLastSegment("/a/"))
|
assertEquals("/a", removeLastSegment("/a/"))
|
||||||
assertEquals("/a", dev.lowrespalmtree.comet.utils.removeLastSegment("/a/b"))
|
assertEquals("/a", removeLastSegment("/a/b"))
|
||||||
assertEquals("/a/b/c", dev.lowrespalmtree.comet.utils.removeLastSegment("/a/b/c/d"))
|
assertEquals("/a/b/c", removeLastSegment("/a/b/c/d"))
|
||||||
assertEquals("//", dev.lowrespalmtree.comet.utils.removeLastSegment("///"))
|
assertEquals("//", removeLastSegment("///"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun popFirstSegment() {
|
fun popFirstSegment() {
|
||||||
assertEquals(Pair("", ""), dev.lowrespalmtree.comet.utils.popFirstSegment(""))
|
assertEquals(Pair("", ""), popFirstSegment(""))
|
||||||
assertEquals(Pair("a", ""), dev.lowrespalmtree.comet.utils.popFirstSegment("a"))
|
assertEquals(Pair("a", ""), popFirstSegment("a"))
|
||||||
assertEquals(Pair("/a", ""), dev.lowrespalmtree.comet.utils.popFirstSegment("/a"))
|
assertEquals(Pair("/a", ""), popFirstSegment("/a"))
|
||||||
assertEquals(Pair("/a", "/"), dev.lowrespalmtree.comet.utils.popFirstSegment("/a/"))
|
assertEquals(Pair("/a", "/"), popFirstSegment("/a/"))
|
||||||
assertEquals(Pair("/a", "/b"), dev.lowrespalmtree.comet.utils.popFirstSegment("/a/b"))
|
assertEquals(Pair("/a", "/b"), popFirstSegment("/a/b"))
|
||||||
assertEquals(Pair("a", "/b"), dev.lowrespalmtree.comet.utils.popFirstSegment("a/b"))
|
assertEquals(Pair("a", "/b"), popFirstSegment("a/b"))
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in a new issue