Skip to content

Commit e182803

Browse files
committed
added tests
1 parent e7a3a1f commit e182803

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/system/test_filesystem.f90

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module test_filesystem
22
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
44
use stdlib_error, only: state_type
55

66
implicit none
@@ -13,6 +13,7 @@ subroutine collect_suite(testsuite)
1313
type(unittest_type), allocatable, intent(out) :: testsuite(:)
1414

1515
testsuite = [ &
16+
new_unittest("FS_ERROR", test_FS_ERROR), &
1617
new_unittest("fs_is_directory_dir", test_is_directory_dir), &
1718
new_unittest("fs_is_directory_file", test_is_directory_file), &
1819
new_unittest("fs_delete_non_existent", test_delete_file_non_existent), &
@@ -21,6 +22,24 @@ subroutine collect_suite(testsuite)
2122
]
2223
end subroutine collect_suite
2324

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+
2443
! Test `is_directory` for a directory
2544
subroutine test_is_directory_dir(error)
2645
type(error_type), allocatable, intent(out) :: error

0 commit comments

Comments
 (0)