Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#32 #34

Merged
merged 4 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/bib2df_gather.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bib2df_gather <- function(bib) {

categories <- lapply(itemslist,
function(x) {
str_extract(x, "[:graph:]+")
str_extract(x, "[[:alnum:]_]+")
}
)

Expand Down
8 changes: 8 additions & 0 deletions inst/extdata/bib2df_testfile_4.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@ARTICLE{Foo1,
author={Foo, B},
title ={The Foo},
journal ={Proceedings of Something},
year ={2009},
abstract ={Bla bla bla.},
author_keywords={foo,foo}
}
14 changes: 14 additions & 0 deletions tests/testthat/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,17 @@ test_that("bib2df() allows '@' and '=' in fields", {
expect_true(identical(bib$TITLE[1], "The C@C60 endohedral complex"))
expect_true(identical(bib$ABSTRACT[1], "Foo bar (F-st = 0.81, P < 0.001) bla bla."))
})

context("Allow for tags with _ and without spaces before =")

test_that("bib2df() allows any number of blanks before =", {
bib <- bib2df(system.file("extdata", "bib2df_testfile_4.bib", package = "bib2df"))
supplied_cols <- c("AUTHOR", "TITLE", "JOURNAL", "YEAR", "ABSTRACT")
expect_false(any(is.na(bib[supplied_cols])))
})

test_that("bib2df() allows for _ in tab name", {
bib <- bib2df(system.file("extdata", "bib2df_testfile_4.bib", package = "bib2df"))
supplied_col <- "AUTHOR_KEYWORDS"
expect_false(any(is.na(bib[supplied_col])))
})