Skip to content

Commit aad5f56

Browse files
committed
Sanity test for Path::equals
1 parent 70b706f commit aad5f56

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/common/test/files/SmokeFileTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,19 @@ class SmokeFileTest {
250250
assertEquals(-1L, FileSystem.System.metadataOrNull(path.parent!!)!!.size)
251251
}
252252

253+
@Test
254+
fun pathEquality() {
255+
val p0 = Path("/", "a", "b", "c")
256+
assertEquals(p0, p0)
257+
258+
assertEquals(p0, Path("/", "a", "b", "c"))
259+
260+
// Paths compared by the string representation, so even if two Paths represent
261+
// the same entity in the file system, they may not be equal
262+
// (but it depends on how a platform treats paths).
263+
assertNotEquals(p0, Path(p0, "d", ".."))
264+
}
265+
253266
private fun constructAbsolutePath(vararg parts: String): String {
254267
return Path.separator.toString() + parts.joinToString(Path.separator.toString())
255268
}

0 commit comments

Comments
 (0)