1
1
module test_filesystem
2
2
use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test
3
- use stdlib_system, only: is_directory, delete_file
3
+ use stdlib_system, only: is_directory, delete_file, FS_ERROR, FS_ERROR_CODE
4
4
use stdlib_error, only: state_type
5
5
6
6
implicit none
@@ -13,6 +13,7 @@ subroutine collect_suite(testsuite)
13
13
type (unittest_type), allocatable , intent (out ) :: testsuite(:)
14
14
15
15
testsuite = [ &
16
+ new_unittest(" FS_ERROR" , test_FS_ERROR), &
16
17
new_unittest(" fs_is_directory_dir" , test_is_directory_dir), &
17
18
new_unittest(" fs_is_directory_file" , test_is_directory_file), &
18
19
new_unittest(" fs_delete_non_existent" , test_delete_file_non_existent), &
@@ -21,6 +22,24 @@ subroutine collect_suite(testsuite)
21
22
]
22
23
end subroutine collect_suite
23
24
25
+ subroutine test_FS_ERROR (error )
26
+ type (error_type), allocatable , intent (out ) :: error
27
+ type (state_type) :: s1, s2
28
+ character (:), allocatable :: msg
29
+
30
+ msg = " code - 10, Cannot create File temp.txt - File already exists"
31
+ s1 = FS_ERROR_CODE(10 , " Cannot create File temp.txt -" , " File already exists" )
32
+
33
+ call check(error, s1% message == msg, " FS_ERROR: Could not construct message with code correctly" )
34
+ if (allocated (error)) return
35
+
36
+ msg = " Cannot create File temp.txt - File already exists"
37
+ s2 = FS_ERROR(" Cannot create File temp.txt -" , " File already exists" )
38
+
39
+ call check(error, s2% message == msg, " FS_ERROR: Could not construct message without code correctly" )
40
+ if (allocated (error)) return
41
+ end subroutine test_FS_ERROR
42
+
24
43
! Test `is_directory` for a directory
25
44
subroutine test_is_directory_dir (error )
26
45
type (error_type), allocatable , intent (out ) :: error
0 commit comments