Skip to content

Commit 4990d38

Browse files
committed
Add test case for File and Path assertions
1 parent 59a43f7 commit 4990d38

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

assertk/src/jvmTest/kotlin/test/assertk/assertions/FileTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ class FileTest {
207207
assertThat(fileWithText).text().contains("Forty-two")
208208
}
209209

210+
//region bytes
211+
@Test
212+
fun hasBytes_correct_value_passes() {
213+
assertThat(fileWithText).bytes().isEqualTo(fileWithText.readBytes())
214+
}
215+
//endregion
216+
210217
@Test
211218
fun contains_wrong_substring_fails() {
212219
val error = assertFailsWith<AssertionError> {

assertk/src/jvmTest/kotlin/test/assertk/assertions/PathTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ class PathTest {
5959
}
6060
//endregion
6161

62+
63+
//region isExecutable
64+
@Test
65+
fun isExecutable_value_regular_file_executable_passes() {
66+
regularFile!!.toFile().setExecutable(true)
67+
assertThat(regularFile!!).isExecutable()
68+
}
69+
70+
@Test
71+
fun isExecutable_value_regular_file_not_executable_fails() {
72+
val error = assertFailsWith<AssertionError> {
73+
assertThat(regularFile!!).isExecutable()
74+
}
75+
assertEquals("expected <$regularFile> to be an executable, but it is not", error.message)
76+
}
77+
//endregion
78+
6279
//region isHidden
6380
@Test
6481
fun isHidden_value_regular_file_not_hidden_fails() {

0 commit comments

Comments
 (0)