Skip to content

Commit

Permalink
Fix #7 double slashes, start working on unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stolarczyk committed Sep 13, 2018
1 parent 21d6a97 commit 53911ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/loadConfig.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ expandPath = function(path) {
if (length(parts) < 2) { return(parts) }
if (identical(".", parts[1])) { parts = parts[2:length(parts)] }

# Expand any environment variables and return the complete path.
# Expand any environment variables and return the complete path
if(.Platform$OS.type=="unix") {
# Prevent double slashes
if(any(parts=="/")){
parts[which(parts=="/")]=""
}
}
fullPath = do.call(file.path, lapply(parts, expand))
return(fullPath)
}
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test_utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
context("Utils")

DF=mtcars
newDF=listifyDF(DF)

test_that("listifyDF is a yields correct object type", {
expect_is(listifyDF(DF = DF),'data.frame')
expect_is(listifyDF(DF = DF)[[1]],'list')
})

test_that("listifyDF does not change the dimensions",{
expect_equal(dim(listifyDF(DF)), dim(DF))
})

0 comments on commit 53911ff

Please sign in to comment.