File: test-trim.r

package info (click to toggle)
r-cran-stringr 0.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 308 kB
  • sloc: makefile: 3
file content (20 lines) | stat: -rw-r--r-- 615 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
context("Trimming strings")

test_that("trimming removes spaces", {
  is_trimmed <- equals("abc")
  expect_that(str_trim("abc   "), is_trimmed)
  expect_that(str_trim("  abc"), is_trimmed)
  expect_that(str_trim("  abc   "), is_trimmed)
})

test_that("trimming removes tabs", {
  is_trimmed <- equals("abc")
  expect_that(str_trim("abc\t"), is_trimmed)
  expect_that(str_trim("\tabc"), is_trimmed)
  expect_that(str_trim("\tabc\t"), is_trimmed)
})

test_that("side argument restricts trimming", {
  expect_that(str_trim(" abc ", "left"), equals("abc "))
  expect_that(str_trim(" abc ", "right"), equals(" abc"))
})