Skip to content

Commit

Permalink
created test_001_vcfR.R
Browse files Browse the repository at this point in the history
  • Loading branch information
knausb committed Sep 8, 2017
1 parent 0c44ea4 commit a34298b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 38 deletions.
2 changes: 1 addition & 1 deletion R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

timesTwo <- function(x) {
.Call('vcfR_timesTwo', PACKAGE = 'vcfR', x)
.Call('_vcfR_timesTwo', PACKAGE = 'vcfR', x)
}

4 changes: 2 additions & 2 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace Rcpp;

// timesTwo
NumericVector timesTwo(NumericVector x);
RcppExport SEXP vcfR_timesTwo(SEXP xSEXP) {
RcppExport SEXP _vcfR_timesTwo(SEXP xSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Expand All @@ -18,7 +18,7 @@ END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"vcfR_timesTwo", (DL_FUNC) &vcfR_timesTwo, 1},
{"_vcfR_timesTwo", (DL_FUNC) &_vcfR_timesTwo, 1},
{NULL, NULL, 0}
};

Expand Down
49 changes: 49 additions & 0 deletions tests/testthat/test_001_vcfR.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

#
library(testthat)
#detach(package:vcfR, unload=TRUE)
#
library(vcfR)

#
context("vcfR functions")


##### ##### ##### ##### #####
#
# vcfR class.
#
##### ##### ##### ##### #####


test_that("We can create an empty vcfR object",{
myvcf <- methods::new("vcfR")

expect_is(myvcf@meta, "character")
expect_equal(length(myvcf@meta), 0)

expect_is(myvcf@fix, "matrix")
expect_equal(nrow(myvcf@fix), 0)
expect_equal(ncol(myvcf@fix), 8)

expect_is(myvcf@gt, "matrix")
expect_equal(nrow(myvcf@gt), 0)
expect_equal(ncol(myvcf@gt), 0)

})


test_that("vcfR subsetters works",{
data(vcfR_example)
# Rows
vcf2 <- vcf[1:10,]
expect_equal(nrow(vcf2@fix), 10)
expect_equal(nrow(vcf2@gt), 10)

# Columns
vcf2 <- vcf[,1:4]
expect_equal(ncol(vcf2@fix), 8)
expect_equal(ncol(vcf2@gt), 4)
})


36 changes: 1 addition & 35 deletions tests/testthat/test_1_vcf.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,9 @@ setwd( test_dir )
#ex_file <- paste(test_dir, "/test.vcf.gz", sep="")
ex_file <- "test.vcf.gz"

write.vcf(vcf, file=ex_file)
#write.vcf(vcf, file=ex_file)


##### ##### ##### ##### #####
#
# vcfR class.
#
##### ##### ##### ##### #####


test_that("We can create an empty vcfR object",{
myvcf <- methods::new("vcfR")

expect_is(myvcf@meta, "character")
expect_equal(length(myvcf@meta), 0)

expect_is(myvcf@fix, "matrix")
expect_equal(nrow(myvcf@fix), 0)
expect_equal(ncol(myvcf@fix), 8)

expect_is(myvcf@gt, "matrix")
expect_equal(nrow(myvcf@gt), 0)
expect_equal(ncol(myvcf@gt), 0)

})


##### ##### ##### ##### #####
Expand Down Expand Up @@ -349,17 +327,6 @@ test_that("read.vcfR verbose works",{
##### ##### ##### ##### #####


test_that("vcfR subsetters works",{
# Rows
vcf2 <- vcf[1:10,]
expect_equal(nrow(vcf2@fix), 10)
expect_equal(nrow(vcf2@gt), 10)

# Columns
vcf2 <- vcf[,1:4]
expect_equal(ncol(vcf2@fix), 8)
expect_equal(ncol(vcf2@gt), 4)
})


#debug(read.vcfR)
Expand Down Expand Up @@ -427,4 +394,3 @@ setwd(original_dir)

##### ##### ##### ##### #####
# EOF.

0 comments on commit a34298b

Please sign in to comment.