1library(pystr) 2context("pystr_index") 3 4test_that("it gives the index if sub exists", { 5 expect_equal(pystr_index("abcd", "ab"), 1) 6}) 7 8test_that("it throws an error if sub does not exist", { 9 expect_error(pystr_index("abcd", "xy")) 10}) 11 12test_that("it respects start / end args", { 13 expect_equal(pystr_index("12121212", "12", 4, 6), 5) 14}) 15 16test_that("it works with a character vector", { 17 expect_equal(pystr_index(c("abcabc", "xyabc"), "abc"), c(1, 3)) 18}) 19 20test_that("it works with multiple character vectors", { 21 expect_equal(pystr_index(c("abcabc", "xyabc"), c("abc", "xy")), c(1, 1)) 22}) 23