File: test-debug.R

package info (click to toggle)
r-cran-wkutils 0.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 816 kB
  • sloc: cpp: 3,625; sh: 12; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 1,134 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

test_that("debugger works on wkb", {
  point <- as.raw(c(0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00, 0x3e, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x24, 0x40))

  expect_output(wkb_debug(list(point)), "POINT \\[1\\]")

  point_bad_type <- point
  point_bad_type[2] <- as.raw(0xff)
  expect_output(wkb_debug(list(point_bad_type)), "Invalid integer geometry type")
})

test_that("debugger works on wkt stream", {
  expect_output(wkt_streamer_debug("LINESTRING (30 10, 0 0, 0 1)"), "LINESTRING")
  expect_output(wkt_streamer_debug("POLYGON ((30 10, 0 0, 0 1, 30 10))"), "POLYGON")
  expect_output(wkt_streamer_debug("MULTIPOINT (30 10, 0 0)"), "MULTIPOINT")
  expect_output(wkt_streamer_debug("MULTIPOINT ((30 10), (0 0))"), "MULTIPOINT")
})

test_that("debugger works on wkt", {
  expect_output(wkt_debug("LINESTRING (30 10, 0 0, 0 1)"), "LINESTRING")
  expect_output(wkt_debug("POLYGON ((30 10, 0 0, 0 1, 30 10))"), "POLYGON")
  expect_output(wkt_debug("MULTIPOINT (30 10, 0 0)"), "MULTIPOINT")
  expect_output(wkt_debug("MULTIPOINT ((30 10), (0 0))"), "MULTIPOINT")
})