-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor get_elements_by_type(), use pipe
and utility function remove_first_and_last_slash()
- Loading branch information
Showing
3 changed files
with
70 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
# | ||
# This test file has been generated by kwb.test::create_test_files() | ||
# launched by user hauke on 2021-11-27 17:51:42. | ||
# Your are strongly encouraged to modify the dummy functions | ||
# so that real cases are tested. You should then delete this comment. | ||
# | ||
#library(testthat) | ||
|
||
test_that("extract_by_path() works", { | ||
|
||
expect_error( | ||
kwb.code:::extract_by_path() | ||
# Argument "paths" fehlt (ohne Standardwert) | ||
f <- kwb.code:::extract_by_path | ||
|
||
expect_error(f()) | ||
expect_error(f("a")) | ||
|
||
x <- list( | ||
list( # [[1]] | ||
11, | ||
12 | ||
), | ||
list( # [[2]] | ||
21, | ||
22, | ||
list( | ||
231, | ||
232 | ||
) | ||
) | ||
) | ||
|
||
|
||
expect_identical(f(x, "1"), x[1L]) | ||
expect_identical(f(x, c("1", "2")), x[c(1, 2)]) | ||
expect_identical(f(x, c("/1/1", "2/2", "/2/3/2")), list(11, 22, 232)) | ||
}) | ||
|