Skip to content

Commit a0beb5b

Browse files
committed
Add test for package without registered functions
Fixes #29
1 parent d35ecde commit a0beb5b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/testthat/helper.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ glue_str <- function(...) {
1919
read_file <- function(x) {
2020
readChar(x, file.size(x))
2121
}
22+
23+
expect_error_free <- function(..., regexp = NA) {
24+
expect_error(..., regexp = regexp)
25+
}

tests/testthat/test-register.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,15 @@ extern \"C\" void R_init_testPkg(DllInfo* dll){
604604
)
605605
)
606606
})
607+
608+
it("does not error if no files have registered functions", {
609+
pkg <- local_package()
610+
p <- pkg_path(pkg)
611+
dir.create(file.path(p, "src"))
612+
writeLines("int foo(int x) { return x; }", file.path(p, "src", "foo.cpp"))
613+
614+
expect_error_free(cpp_register(p))
615+
})
607616
})
608617

609618
describe("generate_init_functions", {

0 commit comments

Comments
 (0)