1library(pystr) 2context("pystr_find") 3 4test_that("it finds the lowest index of the substring", { 5 expect_equal(pystr_find("abcabc", "abc"), 1) 6}) 7 8test_that("it finds the lowest index of the substring within start and end", { 9 expect_equal(pystr_find("abcabc", "abc", 2), 4) 10}) 11 12test_that("it returns -1 when the substring isn't there", { 13 expect_equal(pystr_find("abc", "xy"), -1) 14}) 15 16test_that("it finds the index when start and end both truncated", { 17 expect_equal(pystr_find("abcxyzabc", "xyz", 4, 7), 4) 18}) 19 20test_that("it works with a character vector", { 21 expect_equal(pystr_find(c("abcabc", "xyabc"), "abc"), c(1, 3)) 22}) 23 24 25test_that("it works with multiple character vectors", { 26 expect_equal(pystr_find(c("abcabc", "xyabc"), c("abc", "xy")), c(1, 1)) 27}) 28