Skip to content

Commit

Permalink
Tests: Add tests for SearchWordInString
Browse files Browse the repository at this point in the history
  • Loading branch information
t-b committed Oct 3, 2023
1 parent 6edef6d commit a3ee26b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Packages/tests/Basic/UTF_Utils.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -7230,3 +7230,26 @@ static Function TestRemoveEndingRegex()
CHECK_NO_RTE()
endtry
End

Function TestSearchWordInString()

variable ret
string prefix, suffix

ret = SearchWordInString("ab cd efgh", "ijk")
CHECK_EQUAL_VAR(ret, 0)

// no match as no word boundary after "c"
ret = SearchWordInString("ab cd efgh", "c")
CHECK_EQUAL_VAR(ret, 0)

// match
ret = SearchWordInString("ab cd efgh", "cd")
CHECK_EQUAL_VAR(ret, 1)

// match with prefix and suffix
ret = SearchWordInString("ab#cd?efgh", "cd", prefix = prefix, suffix = suffix)
CHECK_EQUAL_VAR(ret, 1)
CHECK_EQUAL_STR(prefix, "ab#")
CHECK_EQUAL_STR(suffix, "?efgh")
End

0 comments on commit a3ee26b

Please sign in to comment.