File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
jvmMain/kotlin/assertk/assertions
jvmTest/kotlin/test/assertk/assertions Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,12 @@ fun Assert<File>.isFile() = given { actual ->
6464 expected(" to be a file" )
6565}
6666
67+ /* * Assert that the file is an executable. */
68+ fun Assert<File>.canExecute () = given { actual ->
69+ if (actual.canExecute()) return
70+ expected(" to be executable" )
71+ }
72+
6773/* *
6874 * Asserts the file is hidden.
6975 * @see [isNotHidden]
Original file line number Diff line number Diff line change @@ -58,6 +58,22 @@ class FileTest {
5858 }
5959 // endregion
6060
61+ // region canExecute
62+ @Test
63+ fun canExecute_value_regular_file_passes () {
64+ file.setExecutable(true )
65+ assertThat(file).canExecute()
66+ }
67+
68+ @Test
69+ fun canExecute_value_directory_fails () {
70+ val error = assertFailsWith<AssertionError > {
71+ assertThat(file).canExecute()
72+ }
73+ assertEquals(" expected to be executable" , error.message)
74+ }
75+ // endregion
76+
6177 // region isNotHidden
6278 @Test
6379 fun isNotHidden_value_regular_file_passes () {
You can’t perform that action at this time.
0 commit comments