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