1library(pystr)
2context("pystr_rindex")
3
4test_that("it returns the highest index if sub exists", {
5  expect_equal(pystr_rindex("abcdab", "ab"), 5)
6})
7
8test_that("it throws an error if sub doesn't exist", {
9  expect_error(pystr_rindex("abcd", "xy"))
10})
11
12test_that("it works with a character vector", {
13  expect_equal(pystr_rindex(c("123123", "123"), "123"), c(4, 1))
14})
15
16test_that("it respsects start / end args", {
17 expect_equal(pystr_rindex("12121212", "12", 4, 6), 5)
18})
19
20test_that("it works with multiple character vectors", {
21  expect_equal(pystr_rindex(c("123123", "123"), c("123", "3")), c(4, 3))
22})
23