File: test-utils.R

package info (click to toggle)
r-cran-dbplyr 2.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,376 kB
  • sloc: sh: 13; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 898 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
test_that("deparse_trunc() expression to text", {
  expect_equal(
    deparse_trunc(expr(test)),
    "test"
  )

  dt <- deparse_trunc(
    expr(!!paste0(rep("x", 200), collapse = ""))
  )
  expect_equal(
    nchar(dt),
    getOption("width")
  )
})

test_that("Says 1.1 is not a whole number", {
  expect_false(is.wholenumber(1.1))
})

test_that("Succesful and not-sucessful commands are identified", {
  expect_true(succeeds("success"))
  expect_false(succeeds(x - 1, quiet = TRUE))
})

test_that("Dots are collapsed into a single variable", {
  expect_equal(
    named_commas(x = 1, y = 2),
    "x = 1, y = 2"
  )
  expect_equal(
    named_commas(1, 2),
    "1, 2"
  )
})

test_that("Correctly identifies the Travis flag", {
  expect_equal(
    in_travis(),
    Sys.getenv("TRAVIS") == "true"
  )
})

test_that("Returns error if no characters are passed", {
  expect_error(c_character(1, 2))
})