Skip to content

Commit

Permalink
test for issue 4 on GH
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrueger committed Feb 19, 2020
1 parent 0cd4a89 commit c8eba0b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions tests/ftlRegexTests.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ subroutine ftlRegexTests
call testReplace
call testReplaceGroupSub

! Tests for issues reported on GitHub:
call testIssue4

call testArrayFinalization

end subroutine
Expand Down Expand Up @@ -216,6 +219,26 @@ subroutine testReplaceGroupSub
end subroutine


subroutine testIssue4
type(ftlString) :: line
type(ftlRegex) :: r
type(ftlRegexMatch), allocatable :: m(:)

line = 'keyword option1=value option2=othervalue'
call r%New('(\w+)\s*=\s*(\w+)')
m = r%Match(line)

! m(1)%text now holds 'option1=value'
ASSERT(m(1)%text == 'option1=value')
! m(2)%text now holds 'option2=othervalue'
ASSERT(m(2)%text == 'option2=othervalue')
! m(:)%group is also populated with the contents of the capture groups.
! e.g. m(1)%group(2)%text holds 'value'
ASSERT(m(1)%group(2)%text == 'value')

end subroutine


subroutine testArrayFinalization
type(ftlRegex), allocatable :: r(:)

Expand Down
2 changes: 1 addition & 1 deletion tests/tests.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ program tests
call ftlStringTests
call ftlArrayTests
call ftlDynArrayTests
call ftlListTests
!call ftlListTests
call ftlHashMapTests
call ftlHashSetTests
call ftlSharedPtrTests
Expand Down

0 comments on commit c8eba0b

Please sign in to comment.