Skip to content

Commit

Permalink
add tests to address #132
Browse files Browse the repository at this point in the history
  • Loading branch information
zkamvar committed Mar 1, 2016
1 parent cf8d6b5 commit 8842935
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/testthat/test_import.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,31 @@ C45, 0205 0909 0202 0000 0405
expect_warning(gp <- read.genepop(tmp))
expect_identical(indNames(gp), .genlab("", nInd(gp)))

})



test_that("df2genind can handle periods in input", {
skip_on_cran()
dat <-
data.frame(
pop = c(1, 1, 2, 2),
loc1 = c("1/1", "1/2", "1.1/2", "2/2"),
loc2 = c("1/1", "1/2", "1/2", "2/2")
)
expect_warning(datgi <- df2genind(dat[, -1], sep = "/", pop = dat[, 1]))
expect_equivalent(alleles(datgi)$loc1, c("1", "2", "1_1"))
})

test_that("df2genind can handle periods in input with underscore separator", {
skip_on_cran()
dat <-
data.frame(
pop = c(1, 1, 2, 2),
loc1 = c("1/1", "1/2", "1.1/2", "2/2"),
loc2 = c("1/1", "1/2", "1/2", "2/2")
)
dat <- apply(dat, 2, function(i) gsub("/", "_", i))
expect_warning(datgi <- df2genind(dat[, -1], sep = "_", pop = dat[, 1]))
expect_equivalent(alleles(datgi)$loc1, c("1", "2", "1p1"))
})

0 comments on commit 8842935

Please sign in to comment.