The ParaMonte Documentation Website
Current view: top level - kernel/tests - Test_Path_mod.f90 (source / functions) Hit Total Coverage
Test: ParaMonte 1.5.1 :: Coarray Parallel Kernel - Code Coverage Report Lines: 238 238 100.0 %
Date: 2021-01-08 12:59:07 Functions: 21 21 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       2             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       3             : !!!!
       4             : !!!!   MIT License
       5             : !!!!
       6             : !!!!   ParaMonte: plain powerful parallel Monte Carlo library.
       7             : !!!!
       8             : !!!!   Copyright (C) 2012-present, The Computational Data Science Lab
       9             : !!!!
      10             : !!!!   This file is part of the ParaMonte library.
      11             : !!!!
      12             : !!!!   Permission is hereby granted, free of charge, to any person obtaining a
      13             : !!!!   copy of this software and associated documentation files (the "Software"),
      14             : !!!!   to deal in the Software without restriction, including without limitation
      15             : !!!!   the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16             : !!!!   and/or sell copies of the Software, and to permit persons to whom the
      17             : !!!!   Software is furnished to do so, subject to the following conditions:
      18             : !!!!
      19             : !!!!   The above copyright notice and this permission notice shall be
      20             : !!!!   included in all copies or substantial portions of the Software.
      21             : !!!!
      22             : !!!!   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      23             : !!!!   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      24             : !!!!   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      25             : !!!!   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
      26             : !!!!   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
      27             : !!!!   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
      28             : !!!!   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      29             : !!!!
      30             : !!!!   ACKNOWLEDGMENT
      31             : !!!!
      32             : !!!!   ParaMonte is an honor-ware and its currency is acknowledgment and citations.
      33             : !!!!   As per the ParaMonte library license agreement terms, if you use any parts of
      34             : !!!!   this library for any purposes, kindly acknowledge the use of ParaMonte in your
      35             : !!!!   work (education/research/industry/development/...) by citing the ParaMonte
      36             : !!!!   library as described on this page:
      37             : !!!!
      38             : !!!!       https://github.com/cdslaborg/paramonte/blob/main/ACKNOWLEDGMENT.md
      39             : !!!!
      40             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      41             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      42             : 
      43             : !>  \brief This module contains tests of the module [Path_mod](@ref path_mod).
      44             : !>  \author Amir Shahmoradi
      45             : 
      46             : module Test_Path_mod
      47             : 
      48             :     use Path_mod
      49             :     use Test_mod, only: Test_type
      50             :     implicit none
      51             : 
      52             :     private
      53             :     public :: test_Path
      54             : 
      55             :     type(Test_type) :: Test
      56             : 
      57             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      58             : 
      59             : contains
      60             : 
      61             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      62             : 
      63           3 :     subroutine test_Path()
      64             : 
      65             :         implicit none
      66             : 
      67           3 :         Test = Test_type(moduleName=MODULE_NAME)
      68           3 :         call Test%run(test_isdir_1, "test_isdir_1")
      69           3 :         call Test%run(test_query_1, "test_query_1")
      70           3 :         call Test%run(test_query_2, "test_query_2")
      71           3 :         call Test%run(test_query_3, "test_query_3")
      72           3 :         call Test%run(test_mkdir_1, "test_mkdir_1")
      73           3 :         call Test%run(test_mkdir_2, "test_mkdir_2")
      74           3 :         call Test%run(test_mkdir_3, "test_mkdir_3")
      75           3 :         call Test%run(test_modify_1, "test_modify_1")
      76           3 :         call Test%run(test_winify_1, "test_winify_1")
      77           3 :         call Test%run(test_winify_2, "test_winify_2")
      78           3 :         call Test%run(test_winify_3, "test_winify_3")
      79           3 :         call Test%run(test_linify_1, "test_linify_1")
      80           3 :         call Test%run(test_linify_2, "test_linify_2")
      81           3 :         call Test%run(test_getNameExt_1, "test_getNameExt_1")
      82           3 :         call Test%run(test_getNameExt_2, "test_getNameExt_2")
      83           3 :         call Test%run(test_constructPath, "test_constructPath")
      84           3 :         call Test%run(test_getDirNameExt_1, "test_getDirNameExt_1")
      85           3 :         call Test%run(test_getDirNameExt_2, "test_getDirNameExt_2")
      86           3 :         call Test%run(test_getDirFullName_1, "test_getDirFullName_1")
      87           3 :         call Test%run(test_getDirFullName_2, "test_getDirFullName_2")
      88           3 :         call Test%finalize()
      89             : 
      90           3 :     end subroutine test_Path
      91             : 
      92             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      93             : 
      94             :     !> \brief
      95             :     !> Test if `isdir()` can successfully detect an existing directory.
      96           3 :     function test_isdir_1() result(assertion)
      97           3 :         use Constants_mod, only: RK
      98             :         implicit none
      99             :         logical         :: assertion
     100           3 :         assertion = isdir("../")
     101           3 :     end function test_isdir_1
     102             : 
     103             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     104             : 
     105             :     !> \brief
     106             :     !> When the original path is not allocated, `guery()` must return an error message.
     107           3 :     function test_query_1() result(assertion)
     108             : 
     109             :         !use String_mod, only: num2str
     110             :         implicit none
     111             :         logical         :: assertion
     112           3 :         type(Path_type) :: Path
     113             : 
     114           3 :         Path = Path_type(inputPath="")
     115           3 :         assertion = .not. Path%Err%occurred
     116           3 :         if (.not. assertion) return
     117             : 
     118           3 :         deallocate(Path%original)
     119           3 :         call Path%query()
     120           3 :         assertion = Path%Err%occurred
     121             : 
     122           6 :     end function test_query_1
     123             : 
     124             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     125             : 
     126             :     !> \brief
     127             :     !> When the original path is allocated but is empty, `guery()` must return an error message.
     128           3 :     function test_query_2() result(assertion)
     129             : 
     130             :         !use String_mod, only: num2str
     131             :         implicit none
     132             :         logical         :: assertion
     133           3 :         type(Path_type) :: Path
     134             : 
     135           3 :         Path = Path_type(inputPath="")
     136           3 :         assertion = .not. Path%Err%occurred
     137           3 :         if (.not. assertion) return
     138             : 
     139           3 :         Path%original = ""
     140           3 :         call Path%query()
     141           3 :         assertion = Path%Err%occurred
     142             : 
     143           6 :     end function test_query_2
     144             : 
     145             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     146             : 
     147             :     !> \brief
     148             :     !> When the optional OS is provided, the results must be the same as when it is not provided.
     149           3 :     function test_query_3() result(assertion)
     150             : 
     151           3 :         use System_mod, only: OS_type
     152             :         implicit none
     153             :         logical         :: assertion
     154           3 :         type(Path_type) :: Path1, Path2
     155           3 :         type(OS_type)   :: OS
     156             : 
     157           3 :         call OS%query()
     158           3 :         assertion = .not. OS%Err%occurred
     159           3 :         if (.not. assertion) return
     160             : 
     161           3 :         Path1 = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
     162           3 :         assertion = .not. Path1%Err%occurred
     163           3 :         if (.not. assertion) return
     164             : 
     165           3 :         Path2 = Path_type(inputPath="./temp\ Folder/\{inside\}\/", OS = OS)
     166           3 :         assertion = .not. Path2%Err%occurred
     167           3 :         if (.not. assertion) return
     168             : 
     169           3 :         assertion = Path1%modified == Path2%modified
     170             : 
     171           3 :     end function test_query_3
     172             : 
     173             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     174             : 
     175           3 :     function test_constructPath() result(assertion)
     176             : 
     177             :         !use String_mod, only: num2str
     178             :         implicit none
     179             :         logical         :: assertion
     180           3 :         type(Path_type) :: Path
     181             : 
     182           3 :         Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
     183           3 :         assertion = .not. Path%Err%occurred
     184           3 :         if (.not. assertion) return
     185             : 
     186           3 :         assertion = Path%original == "./temp\ Folder/\{inside\}\/"
     187           3 :         if (Test%isDebugMode .and. .not. assertion) then
     188             :         ! LCOV_EXCL_START
     189             :             write(Test%outputUnit,"(*(g0,:,' '))")
     190             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%original  :", Path%original
     191             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%modified  :", Path%modified
     192             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%shellSlash:", Path%shellSlash
     193             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%dir       :", Path%dir
     194             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%name      :", Path%name
     195             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%ext       :", Path%ext
     196             :             write(Test%outputUnit,"(*(g0,:,' '))")
     197             :         end if
     198             :         ! LCOV_EXCL_STOP
     199             : 
     200           6 :     end function test_constructPath
     201             : 
     202             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     203             : 
     204           3 :     function test_winify_1() result(assertion)
     205             : 
     206             :         implicit none
     207             :         logical         :: assertion
     208           3 :         type(Path_type) :: Path
     209             : 
     210           3 :         Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
     211           3 :         assertion = .not. Path%Err%occurred
     212           3 :         if (.not. assertion) return
     213             : 
     214           3 :         Path%original = "./temp\ Folder/\{inside\}/"
     215           3 :         Path%modified = winify(Path%original)
     216             : 
     217           3 :         assertion = Path%modified == '".\temp Folder\{inside}\"'
     218           3 :         if (Test%isDebugMode .and. .not. assertion) then
     219             :         ! LCOV_EXCL_START
     220             :             write(Test%outputUnit,"(*(g0,:,' '))")
     221             :             write(Test%outputUnit,"(*(g0,:,' '))") Path%original
     222             :             write(Test%outputUnit,"(*(g0,:,' '))") Path%modified
     223             :             write(Test%outputUnit,"(*(g0,:,' '))")
     224             :         end if
     225             :         ! LCOV_EXCL_STOP
     226             : 
     227           6 :     end function test_winify_1
     228             : 
     229             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     230             : 
     231             :     !> \brief
     232             :     !> Test whether the routine can successfully remove multiple backslashes from the path to convert them all to a single slash.
     233           3 :     function test_winify_2() result(assertion)
     234             : 
     235             :         implicit none
     236             :         logical                     :: assertion
     237           3 :         character(:), allocatable   :: modified
     238           3 :         character(:), allocatable   :: original
     239           3 :         original = "\\\"
     240           3 :         modified = winify(original)
     241           3 :         assertion = modified == "\"
     242           3 :         if (Test%isDebugMode .and. .not. assertion) then
     243             :         ! LCOV_EXCL_START
     244             :             write(Test%outputUnit,"(*(g0,:,' '))")
     245             :             write(Test%outputUnit,"(*(g0,:,' '))") original
     246             :             write(Test%outputUnit,"(*(g0,:,' '))") modified
     247             :             write(Test%outputUnit,"(*(g0,:,' '))")
     248             :         end if
     249             :         ! LCOV_EXCL_STOP
     250             : 
     251           6 :     end function test_winify_2
     252             : 
     253             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     254             : 
     255             :     !> \brief
     256             :     !> Test whether the routine can successfully convert a single forward-slash path to a backslash.
     257           3 :     function test_winify_3() result(assertion)
     258             : 
     259             :         implicit none
     260             :         logical                     :: assertion
     261           3 :         character(:), allocatable   :: modified
     262           3 :         character(:), allocatable   :: original
     263           3 :         original = "/"
     264           3 :         modified = winify(original)
     265           3 :         assertion = modified == "\"
     266           3 :         if (Test%isDebugMode .and. .not. assertion) then
     267             :         ! LCOV_EXCL_START
     268             :             write(Test%outputUnit,"(*(g0,:,' '))")
     269             :             write(Test%outputUnit,"(*(g0,:,' '))") original
     270             :             write(Test%outputUnit,"(*(g0,:,' '))") modified
     271             :             write(Test%outputUnit,"(*(g0,:,' '))")
     272             :         end if
     273             :         ! LCOV_EXCL_STOP
     274             : 
     275           6 :     end function test_winify_3
     276             : 
     277             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     278             : 
     279           3 :     function test_linify_1() result(assertion)
     280             : 
     281             :         implicit none
     282             :         logical         :: assertion
     283           3 :         type(Path_type) :: Path
     284             : 
     285           3 :         Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
     286           3 :         assertion = .not. Path%Err%occurred
     287           3 :         if (.not. assertion) return
     288             : 
     289           3 :         Path%original = '".\temp Folder\{inside}\"'
     290           3 :         Path%modified = linify(Path%original)
     291             : 
     292           3 :         assertion = Path%modified == "./temp\ Folder/\{inside\}/"
     293             : 
     294           3 :         if (Test%isDebugMode .and. .not. assertion) then
     295             :         ! LCOV_EXCL_START
     296             :             write(Test%outputUnit,"(*(g0,:,' '))")
     297             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%original     :", Path%original
     298             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%modified     :", Path%modified
     299             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%shellSlash   :", Path%shellSlash
     300             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%dir          :", Path%dir
     301             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%name         :", Path%name
     302             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%ext          :", Path%ext
     303             :             write(Test%outputUnit,"(*(g0,:,' '))")
     304             :         end if
     305             :         ! LCOV_EXCL_STOP
     306             : 
     307           6 :     end function test_linify_1
     308             : 
     309             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     310             : 
     311           3 :     function test_linify_2() result(assertion)
     312             : 
     313             :         implicit none
     314             :         logical         :: assertion
     315           3 :         type(Path_type) :: Path
     316             : 
     317           3 :         Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
     318           3 :         assertion = .not. Path%Err%occurred
     319           3 :         if (.not. assertion) return
     320             : 
     321           3 :         Path%original = '".\temp Folder\{inside}\-"'
     322           3 :         Path%modified = linify(Path%original)
     323             : 
     324           3 :         assertion = Path%modified == "./temp\ Folder/\{inside\}/-"
     325             : 
     326           3 :         if (Test%isDebugMode .and. .not. assertion) then
     327             :         ! LCOV_EXCL_START
     328             :             write(Test%outputUnit,"(*(g0,:,' '))")
     329             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%original     :", Path%original
     330             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%modified     :", Path%modified
     331             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%shellSlash   :", Path%shellSlash
     332             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%dir          :", Path%dir
     333             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%name         :", Path%name
     334             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%ext          :", Path%ext
     335             :             write(Test%outputUnit,"(*(g0,:,' '))")
     336             :         end if
     337             :         ! LCOV_EXCL_STOP
     338             : 
     339           6 :     end function test_linify_2
     340             : 
     341             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     342             : 
     343           3 :     function test_getDirNameExt_1() result(assertion)
     344             : 
     345             :         implicit none
     346             :         logical         :: assertion
     347           3 :         type(Path_type) :: Path
     348             : 
     349           3 :         assertion = .true.
     350             : 
     351           3 :         Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
     352           3 :         assertion = .not. Path%Err%occurred
     353           3 :         if (.not. assertion) return
     354             : 
     355           3 :         Path%original = ".\temp Folder\{inside}\"
     356           3 :         call Path%getDirNameExt(Path%original,"\",Path%dir,Path%name,Path%ext)
     357             : 
     358           3 :         assertion = assertion .and. Path%dir == ".\temp Folder\{inside}\"
     359           3 :         assertion = assertion .and. Path%name == ""
     360           3 :         assertion = assertion .and. Path%ext == ""
     361             : 
     362           3 :         if (Test%isDebugMode .and. .not. assertion) then
     363             :         ! LCOV_EXCL_START
     364             :             write(Test%outputUnit,"(*(g0,:,' '))")
     365             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%dir :", Path%dir
     366             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%name:", Path%name
     367             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%ext :", Path%ext
     368             :             write(Test%outputUnit,"(*(g0,:,' '))")
     369             :         end if
     370             :         ! LCOV_EXCL_STOP
     371             : 
     372           6 :     end function test_getDirNameExt_1
     373             : 
     374             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     375             : 
     376           3 :     function test_getDirNameExt_2() result(assertion)
     377             : 
     378             :         implicit none
     379             :         logical         :: assertion
     380           3 :         type(Path_type) :: Path
     381             : 
     382           3 :         assertion = .true.
     383             : 
     384           3 :         Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
     385           3 :         assertion = .not. Path%Err%occurred
     386           3 :         if (.not. assertion) return
     387             : 
     388           3 :         Path%original = ".\temp Folder\{inside}\Temp.tXt"
     389           3 :         call Path%getDirNameExt(Path%original,"\",Path%dir,Path%name,Path%ext)
     390             : 
     391           3 :         assertion = assertion .and. Path%dir == ".\temp Folder\{inside}\"
     392           3 :         assertion = assertion .and. Path%name == "Temp"
     393           3 :         assertion = assertion .and. Path%ext == ".tXt"
     394             : 
     395           3 :         if (Test%isDebugMode .and. .not. assertion) then
     396             :         ! LCOV_EXCL_START
     397             :             write(Test%outputUnit,"(*(g0,:,' '))")
     398             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%dir :", Path%dir
     399             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%name:", Path%name
     400             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%ext :", Path%ext
     401             :             write(Test%outputUnit,"(*(g0,:,' '))")
     402             :         end if
     403             :         ! LCOV_EXCL_STOP
     404             : 
     405           6 :     end function test_getDirNameExt_2
     406             : 
     407             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     408             : 
     409           3 :     function test_getDirFullName_1() result(assertion)
     410             : 
     411             :         implicit none
     412             :         logical         :: assertion
     413           3 :         type(Path_type) :: Path
     414             : 
     415           3 :         assertion = .true.
     416             : 
     417           3 :         Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
     418           3 :         assertion = .not. Path%Err%occurred
     419           3 :         if (.not. assertion) return
     420             : 
     421           3 :         Path%original = ".\temp Folder\{inside}\-"
     422           3 :         call Path%getDirFullName(Path%original,"\",Path%dir,Path%name)
     423             : 
     424           3 :         assertion = assertion .and. Path%dir == ".\temp Folder\{inside}\"
     425           3 :         assertion = assertion .and. Path%name == "-"
     426             : 
     427           3 :         if (Test%isDebugMode .and. .not. assertion) then
     428             :         ! LCOV_EXCL_START
     429             :             write(Test%outputUnit,"(*(g0,:,' '))")
     430             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%dir :", Path%dir
     431             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%name:", Path%name
     432             :             write(Test%outputUnit,"(*(g0,:,' '))")
     433             :         end if
     434             :         ! LCOV_EXCL_STOP
     435             : 
     436           6 :     end function test_getDirFullName_1
     437             : 
     438             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     439             : 
     440             :     !> \brief
     441             :     !> When the filename is all file name without extension (any dots), `getDirFullName()` must return
     442             :     !> the full file name with empty directory.
     443           3 :     function test_getDirFullName_2() result(assertion)
     444             : 
     445             :         implicit none
     446             :         logical         :: assertion
     447           3 :         type(Path_type) :: Path
     448             : 
     449           3 :         assertion = .true.
     450             : 
     451           3 :         Path = Path_type(inputPath="ParaMonte")
     452           3 :         assertion = .not. Path%Err%occurred
     453           3 :         if (.not. assertion) return
     454             : 
     455           3 :         call Path%getDirFullName(Path%original,"\",Path%dir,Path%name)
     456             : 
     457           3 :         assertion = assertion .and. Path%dir == ""
     458           3 :         assertion = assertion .and. Path%name == Path%original
     459             : 
     460           3 :         if (Test%isDebugMode .and. .not. assertion) then
     461             :         ! LCOV_EXCL_START
     462             :             write(Test%outputUnit,"(*(g0,:,' '))")
     463             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%original :", Path%original
     464             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%dir      :", Path%dir
     465             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%name     :", Path%name
     466             :             write(Test%outputUnit,"(*(g0,:,' '))")
     467             :         end if
     468             :         ! LCOV_EXCL_STOP
     469             : 
     470           6 :     end function test_getDirFullName_2
     471             : 
     472             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     473             : 
     474             :     !> \brief
     475             :     !> When the filename is all file extension, `getNameExt()` must return
     476             :     !> an empty file name and an extension equivalent to full file name.
     477           3 :     function test_getNameExt_1() result(assertion)
     478             : 
     479             :         implicit none
     480             :         logical                     :: assertion
     481           3 :         character(:), allocatable   :: name, ext, filename
     482             : 
     483           3 :         assertion = .true.
     484             : 
     485           3 :         filename = ".ParaMonte"
     486           3 :         call getNameExt(filename, name, ext)
     487             : 
     488           3 :         assertion = assertion .and. name == ""
     489           3 :         assertion = assertion .and. ext == filename
     490             : 
     491           3 :         if (Test%isDebugMode .and. .not. assertion) then
     492             :         ! LCOV_EXCL_START
     493             :             write(Test%outputUnit,"(*(g0,:,' '))")
     494             :             write(Test%outputUnit,"(*(g0,:,' '))")   "filename  :", filename
     495             :             write(Test%outputUnit,"(*(g0,:,' '))")   "name      :", name
     496             :             write(Test%outputUnit,"(*(g0,:,' '))")   "ext       :", ext
     497             :             write(Test%outputUnit,"(*(g0,:,' '))")
     498             :         end if
     499             :         ! LCOV_EXCL_STOP
     500             : 
     501           6 :     end function test_getNameExt_1
     502             : 
     503             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     504             : 
     505           3 :     function test_getNameExt_2() result(assertion)
     506             : 
     507             :         implicit none
     508             :         logical         :: assertion
     509           3 :         type(Path_type) :: Path
     510             : 
     511           3 :         assertion = .true.
     512             : 
     513           3 :         Path = Path_type(inputPath="./temp\ Folder/\{inside\}\/")
     514           3 :         assertion = .not. Path%Err%occurred
     515           3 :         if (.not. assertion) return
     516             : 
     517           3 :         Path%original = "-"
     518           3 :         call Path%getNameExt(Path%original,Path%name,Path%ext)
     519             : 
     520           3 :         assertion = assertion .and. Path%name == "-"
     521           3 :         assertion = assertion .and. Path%ext == ""
     522             : 
     523           3 :         if (Test%isDebugMode .and. .not. assertion) then
     524             :         ! LCOV_EXCL_START
     525             :             write(Test%outputUnit,"(*(g0,:,' '))")
     526             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%name:", Path%name
     527             :             write(Test%outputUnit,"(*(g0,:,' '))")   "Path%ext :", Path%ext
     528             :             write(Test%outputUnit,"(*(g0,:,' '))")
     529             :         end if
     530             :         ! LCOV_EXCL_STOP
     531             : 
     532           6 :     end function test_getNameExt_2
     533             : 
     534             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     535             : 
     536             :     !> \brief
     537             :     !> When the filename is all file extension, `getNameExt()` must return
     538             :     !> an empty file name and an extension equivalent to full file name.
     539           3 :     function test_modify_1() result(assertion)
     540             : 
     541           3 :         use System_mod, only: OS_type
     542             :         use Err_mod, only: Err_type
     543             :         implicit none
     544             :         logical                     :: assertion
     545           3 :         character(:), allocatable   :: original, modified, modified_ref
     546           3 :         type(Err_type)              :: Err
     547           3 :         type(OS_type)               :: OS
     548             : 
     549           3 :         original = ".\ParaMonte\dir1 \"
     550           3 :         call modify(original,modified,Err)
     551           3 :         assertion = .not. OS%Err%occurred
     552             :         if (.not. assertion) return ! LCOV_EXCL_LINE
     553             : 
     554           3 :         call OS%query()
     555           3 :         assertion = .not. OS%Err%occurred
     556             :         if (.not. assertion) return ! LCOV_EXCL_LINE
     557             : 
     558           3 :         if (OS%Shell%isUnix) then
     559           3 :             modified_ref = "./ParaMonte/dir1\ /"
     560           3 :             assertion = assertion .and. modified == modified_ref
     561             : #if defined OS_IS_WINDOWS
     562             :         else
     563             :             modified_ref = modified
     564             :             assertion = assertion .and. modified == modified
     565             : #endif
     566             :         end if
     567             : 
     568           3 :         if (Test%isDebugMode .and. .not. assertion) then
     569             :         ! LCOV_EXCL_START
     570             :             write(Test%outputUnit,"(*(g0,:,' '))")
     571             :             write(Test%outputUnit,"(*(g0,:,' '))")   "modified_ref  :", '"'//modified_ref//'"'
     572             :             write(Test%outputUnit,"(*(g0,:,' '))")   "modified      :", '"'//modified//'"'
     573             :             write(Test%outputUnit,"(*(g0,:,' '))")   "original      :", '"'//original//'"'
     574             :             write(Test%outputUnit,"(*(g0,:,' '))")
     575             :         end if
     576             :         ! LCOV_EXCL_STOP
     577             : 
     578           3 :     end function test_modify_1
     579             : 
     580             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     581             : 
     582             :     !> \brief
     583             :     !> Test whether all processors are capable of generating directories.
     584           3 :     function test_mkdir_1() result(assertion)
     585             : 
     586           3 :         use Constants_mod, only: RK
     587             :         use System_mod, only: RandomFileName_type, OS_type
     588             :         implicit none
     589             :         logical                     :: assertion
     590           3 :         type(RandomFileName_type)   :: RFN
     591           3 :         type(OS_type)               :: OS
     592             : 
     593           3 :         RFN = RandomFileName_type(key="test_mkdir_1")
     594           3 :         assertion = .not. RFN%Err%occurred
     595           3 :         if (.not. assertion) return
     596             : 
     597           3 :         call OS%query()
     598           3 :         assertion = .not. OS%Err%occurred
     599           3 :         if (.not. assertion) return
     600             : 
     601           3 :         RFN%Err = mkdir(RFN%path, OS%Shell%isUnix, .true.)
     602           3 :         assertion = .not. RFN%Err%occurred
     603           3 :         if (.not. assertion) return
     604             : 
     605           3 :     end function test_mkdir_1
     606             : 
     607             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     608             : 
     609             :     !> \brief
     610             :     !> Test whether all processors are capable of generating directories.
     611           3 :     function test_mkdir_2() result(assertion)
     612             : 
     613           3 :         use Constants_mod, only: RK
     614             :         use System_mod, only: RandomFileName_type, OS_type
     615             :         implicit none
     616             :         logical                     :: assertion
     617           3 :         type(RandomFileName_type)   :: RFN
     618           3 :         type(OS_type)               :: OS
     619             : 
     620           3 :         RFN = RandomFileName_type(key="test_mkdir_2")
     621           3 :         assertion = .not. RFN%Err%occurred
     622           3 :         if (.not. assertion) return
     623             : 
     624           3 :         call OS%query()
     625           3 :         assertion = .not. OS%Err%occurred
     626           3 :         if (.not. assertion) return
     627             : 
     628           3 :         RFN%Err = mkdir(RFN%path, OS%Shell%isUnix, .false.)
     629           3 :         assertion = .not. RFN%Err%occurred
     630           3 :         if (.not. assertion) return
     631             : 
     632           3 :     end function test_mkdir_2
     633             : 
     634             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     635             : 
     636             :     !> \brief
     637             :     !> Test whether all processors are capable of generating directories, without the input optional arguments
     638           3 :     function test_mkdir_3() result(assertion)
     639             : 
     640           3 :         use System_mod, only: RandomFileName_type
     641             :         use Constants_mod, only: RK
     642             :         implicit none
     643             :         logical                     :: assertion
     644           3 :         type(RandomFileName_type)   :: RFN
     645             : 
     646           3 :         RFN = RandomFileName_type(key="test_mkdir_3")
     647           3 :         assertion = .not. RFN%Err%occurred
     648           3 :         if (.not. assertion) return
     649             : 
     650           3 :         RFN%Err = mkdir(RFN%path)
     651           3 :         assertion = .not. RFN%Err%occurred
     652           3 :         if (.not. assertion) return
     653             : 
     654           3 :     end function test_mkdir_3
     655             : 
     656             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     657             : 
     658             : end module Test_Path_mod ! LCOV_EXCL_LINE

ParaMonte: Plain Powerful Parallel Monte Carlo Library 
The Computational Data Science Lab
© Copyright 2012 - 2021