1library(pystr) 2context("pystr_endswith") 3 4test_that("it works with a string suffix that's present", { 5 expect_true(pystr_endswith("selfie.jpg", ".jpg")) 6}) 7 8test_that("it works with a string suffix that's not present", { 9 expect_false(pystr_endswith("selfie.jpg", ".png")) 10}) 11 12test_that("it works with a start and end range", { 13 expect_true(pystr_endswith("hello world", "ello", 1, 5)) 14}) 15 16test_that("it returns FALSE when start and end are out of bounds", { 17 expect_false(pystr_endswith("hi", "hi", 10, 15)) 18}) 19 20test_that("all strings end with an empty string", { 21 expect_true(pystr_endswith("hello", "")) 22}) 23 24test_that("it works with a character vector", { 25 expect_equal(pystr_endswith(c("selfie.jpg", "selfie.png"), ".jpg"), c(TRUE, FALSE)) 26}) 27 28test_that("it works with multiple character vectors", { 29 expect_equal(pystr_endswith(c("selfie.jpg", "selfie.png"), c(".jpg", ".png")), c(TRUE, TRUE)) 30}) 31