Skip to content

Commit

Permalink
Test opq with adiff
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaspons committed Dec 7, 2022
1 parent ccb8db6 commit 411175a
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/testthat/test-opq.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,59 @@ test_that ("datetime", {
expect_true (grepl ("diff\\:", q2$prefix))
})

test_that ("adiff", {

q0 <- opq (
bbox = c (-0.118, 51.514, -0.115, 51.517),
datetime = "2015-01-01T00:00:00Z"
)
q1 <- opq (
bbox = c (-0.118, 51.514, -0.115, 51.517),
datetime = "2015-01-01T00:00:00Z",
adiff = TRUE
)


expect_true (!identical (q0, q1))
expect_identical (names (q0), names (q1))
expect_identical (
q0 [!names (q0) == "prefix"],
q1 [!names (q1) == "prefix"]
)
expect_true (!grepl ("date\\:", q1$prefix))
expect_true (grepl ("adiff\\:", q1$prefix))

expect_error (
opq (
bbox = c (-0.118, 51.514, -0.115, 51.517),
datetime = "2015-01-01T00:00:00Z",
datetime2 = "blah",
adiff = TRUE
),
"datetime must be in ISO8601 format"
)

q2 <- opq (
bbox = c (-0.118, 51.514, -0.115, 51.517),
datetime = "2015-01-01T00:00:00Z",
datetime2 = "2015-01-02T00:00:00Z"
)
q3 <- opq (
bbox = c (-0.118, 51.514, -0.115, 51.517),
datetime = "2015-01-01T00:00:00Z",
datetime2 = "2015-01-02T00:00:00Z",
adiff = TRUE
)
expect_true (!identical (q2, q3))
expect_identical (names (q2), names (q3))
expect_identical (
q0 [!names (q2) == "prefix"],
q2 [!names (q3) == "prefix"]
)
expect_true (!grepl ("date\\:", q2$prefix))
expect_true (grepl ("adiff\\:", q2$prefix))
})

test_that ("opq_string", {

# bbox only:
Expand Down

0 comments on commit 411175a

Please # to comment.