Reputation: 1707
What's the correct way of testing equality in a symbol?
I've tried
expect_equal( tsibble::index(bngoRawData), "time" )
but it fails with:
tsibble::index(bngoRawData) (`actual`) not equal to "time" (`expected`).
`actual` is a symbol
`expected` is a character vector ('time')
Without the quotes on "time" it complains it's a function instead.
Upvotes: 2
Views: 32
Reputation: 18561
We can use as.name
:
library(tsibble)
library(testthat)
expect_equal(tsibble::index(pedestrian), as.name("Date_Time"))
Alternatively we can use rlang::sym
.
Upvotes: 1