File: test_explode.R

package info (click to toggle)
r-cran-bbmisc 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,256 kB
  • sloc: ansic: 176; sh: 9; makefile: 5
file content (18 lines) | stat: -rw-r--r-- 454 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
context("explode")

test_that("explode", {
  x = "R is a nice programming language"
  substrings = c("R", "is", "a", "nice", "programming", "language")
  sep = " "

  # split string
  exploded = explode(x, sep = sep)
  expect_equal(length(exploded), 6)
  for (i in 1:length(substrings)) {
    expect_equal(substrings[i], exploded[[i]])
  }

  # now glue the substrings together
  collapsed = collapse(exploded, sep = sep)
  expect_equal(collapsed, x)
})