commit fb136a95a87d32685ba342186c77bce2ceeddbc6
parent 01147f08dcb4e82a4f0fd28525267b74ed2f20fe
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date: Fri, 26 Feb 2016 21:59:19 -0500
More tests.
Diffstat:
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/tests/testthat/test_generics.R b/tests/testthat/test_generics.R
@@ -0,0 +1,21 @@
+library(patternapply)
+context("Using generics")
+
+inputStrings <- paste(letters, seq_along(letters), sep = "_")
+patterns <- c("([[:digit:]]{2})",
+ "([[:alpha:]])")
+replacements <- list(c("\\1", "1"),
+ c("\\1", "2"))
+patternapplyResult <- patternapply(inputStrings, patterns, replacements)
+patternapplyResultMatrix <- as.matrix(patternapplyResult)
+patternapplyResultDF <- as.data.frame(patternapplyResult)
+
+test_that("Converting to matrix works", {
+ expect_is(patternapplyResultMatrix, "matrix")
+ expect_equal(ncol(patternapplyResultMatrix), 2)
+})
+
+test_that("Converting to data.frame works", {
+ expect_is(patternapplyResultDF, "data.frame")
+ expect_equal(ncol(patternapplyResultDF), 2)
+})