1library(pystr)
2context("pystr_partition")
3
4test_that("it returns the string itself and two empty strings if sep isn't found", {
5  expect_equal(pystr_partition("abcd", "xy")[[1]], c("abcd", "", ""))
6})
7
8test_that("it returns before, sep, and after if sep is found", {
9  expect_equal(pystr_partition("abcd", "bc")[[1]], c("a", "bc", "d"))
10})
11
12test_that("it returns an empty string at the beginning if sep is at the beginning", {
13  expect_equal(pystr_partition("abcd", "ab")[[1]], c("", "ab", "cd"))
14})
15
16test_that("it returns an empty string at the end if the sep is at the end", {
17  expect_equal(pystr_partition("abcd", "cd")[[1]], c("ab", "cd", ""))
18})
19
20test_that("it returns a list of character vectors", {
21  input = c("A.B.C", "B.C", "C")
22  output = list(c("A", ".", "B.C"), c("B", ".", "C"), c("C", "", ""))
23  expect_equal(pystr_partition(input, "."), output)
24})
25