Skip to content

Commit

Permalink
fix another possible regression for s2/sf
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Dec 26, 2021
1 parent 298f3cf commit cc963b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions R/wkb.R
Expand Up @@ -93,16 +93,18 @@ validate_wk_wkb <- function(x) {
stop("wkb() must be of type list()", call. = FALSE)
}

if (!inherits(x, "wk_wkb") || !inherits(x, "wk_vctr")) {
stop('wkb() must inherit from c("wk_wkb", "wk_vctr")', call. = FALSE)
}

good_types <- .Call(wk_c_wkb_is_raw_or_null, x)
if (!all(good_types)) {
stop("items in wkb input must be raw() or NULL", call. = FALSE)
}

problems <- wk_problems(x)
if (!inherits(x, "wk_wkb") || !inherits(x, "wk_vctr")) {
attributes(x) <- NULL
problems <- wk_problems(new_wk_wkb(x))
} else {
problems <- wk_problems(x)
}

stop_for_problems(problems)

invisible(x)
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-wkb.R
Expand Up @@ -16,7 +16,8 @@ test_that("wkb class works", {
expect_error(wkb(list(raw())), "Encountered 1 parse problem")
expect_error(wkb(rep(list(raw()), 10)), "Encountered 10 parse problems")
expect_error(validate_wk_wkb("char!"), "must be of type list")
expect_error(validate_wk_wkb(list()), "must inherit from")
# See #123 and revert in dev wk after CRAN release
# expect_error(validate_wk_wkb(list()), "must inherit from")

expect_s3_class(x[1], "wk_wkb")
expect_identical(x[[1]], x[1])
Expand Down

0 comments on commit cc963b7

Please sign in to comment.