[Analogue-commits] r367 - in pkg: inst inst/tests tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Oct 5 23:10:47 CEST 2013
Author: gsimpson
Date: 2013-10-05 23:10:47 +0200 (Sat, 05 Oct 2013)
New Revision: 367
Added:
pkg/inst/tests/
pkg/inst/tests/test-new-distance.R
pkg/tests/test-all.R
Log:
add tests
Added: pkg/inst/tests/test-new-distance.R
===================================================================
--- pkg/inst/tests/test-new-distance.R (rev 0)
+++ pkg/inst/tests/test-new-distance.R 2013-10-05 21:10:47 UTC (rev 367)
@@ -0,0 +1,29 @@
+## Tests for the new distance compiled code
+
+## load packages
+library("testthat")
+library_if_available("analogue")
+
+context("Testing new distance compiled code functions")
+
+## simple example using dummy data
+train <- data.frame(matrix(abs(runif(200)), ncol = 10))
+rownames(train) <- LETTERS[1:20]
+colnames(train) <- as.character(1:10)
+fossil <- data.frame(matrix(abs(runif(100)), ncol = 10))
+colnames(fossil) <- as.character(1:10)
+rownames(fossil) <- letters[1:10]
+
+## test methods for x and y
+test_that("distance matches compiled versions for x and y", {
+
+ ## default settings
+ expect_equal(distance(train, fossil),
+ oldDistance(train, fossil))
+
+ ## euclidean
+ method <- "euclidean"
+ expect_equal(distance(train, fossil, method = method),
+ oldDistance(train, fossil, method = method))
+
+})
Added: pkg/tests/test-all.R
===================================================================
--- pkg/tests/test-all.R (rev 0)
+++ pkg/tests/test-all.R 2013-10-05 21:10:47 UTC (rev 367)
@@ -0,0 +1,8 @@
+## Test `analogue` using the `testthat` package
+
+## Setup
+library(testthat)
+library(analogue)
+
+## Runs the tests in inst/tests
+test_package("analogue")
More information about the Analogue-commits
mailing list