summaryrefslogtreecommitdiff
path: root/src/jsTest/kotlin/io/PathTest.kt
blob: 73667a62b4e76b9f95ca0997981a7bd357958026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package io

import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.booleans.shouldBeFalse
import io.kotest.matchers.types.shouldBeTypeOf

class PathTest : FunSpec({
	val homeDir = Path.of("/home") as Path.Absolute
	test("recognize relative paths as such") {
		listOf(
			Path.of("a/b"),
			Path.of("."),
			Path.of("a", "b"),
			Path.ofShell("a/b", userHome = homeDir),
			Path.ofShell(".", userHome = homeDir),
			Path.ofShell("a", "b", userHome = homeDir),
			Path.ofShell(listOf("a", "b"), userHome = homeDir),
		).forEach {
			it.shouldBeTypeOf<Path.Relative>()
		}
	}
	test("recognize absolute paths as such") {
		listOf(
			Path.of("/a/b"),
			Path.of("/"),
			Path.ofShell("/b/c", userHome = homeDir),
		).forEach {
			it.shouldBeTypeOf<Path.Absolute>()
		}
	}
})