Skip to content

Commit

Permalink
# This is a combination of 7 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

default last in strutils.find to -1

# This is the commit message nim-lang#2:

Revert "default last in strutils.find to -1"

This reverts commit 3a99556.

# This is the commit message nim-lang#3:

add openArray variable of find with SkipTable

# This is the commit message nim-lang#4:

add find method that accepts an openArray

# This is the commit message nim-lang#5:

add tests

# This is the commit message nim-lang#6:

Revert "add find method that accepts an openArray"

This reverts commit 2ab5351.

# This is the commit message nim-lang#7:

Revert "add openArray variable of find with SkipTable"

This reverts commit 58159fc.
  • Loading branch information
n5m committed Jan 5, 2022
1 parent 9df195e commit 8744518
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/stdlib/tstrutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,22 @@ template main() =
doAssert "abcd".find("bc", start=1, last=last) == -1
doAssert "abcd".find("bc", start=2, last=last) == -1

# using openArray variant
block:
doAssert "abcde".toOpenArray(0, 4).find("") == 0
doAssert "abcde".toOpenArray(1, 4).find("") == 0
doAssert "abcde".toOpenArray(3, 4).find("") == 0
doAssert "abcde".toOpenArray(4, 4).find("") == 0

doAssert "abcde".toOpenArray(0, 4).find("c") == 2
doAssert "abcde".toOpenArray(1, 4).find("c") == 1
doAssert "abcde".toOpenArray(2, 4).find("c") == 0
doAssert "abcde".toOpenArray(3, 4).find("c") == -1

doAssert "abcde".toOpenArray(0, 4).find("cd") == 2
doAssert "abcde".toOpenArray(1, 4).find("cd") == 1
doAssert "abcde".toOpenArray(3, 4).find("cd") == -1

block: # rfind
doAssert "0123456789ABCDEFGAH".rfind('A') == 17
doAssert "0123456789ABCDEFGAH".rfind('A', last=13) == 10
Expand Down

0 comments on commit 8744518

Please sign in to comment.