summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Sobczak <chris@sobczak.family>2026-06-10 20:54:26 -0700
committerChris Sobczak <chris@sobczak.family>2026-06-10 20:54:26 -0700
commit14cb619997719aac2971b5ef89feacc421764458 (patch)
tree89c90e84b40579d67c0ad72811f2b1719ff70f46 /tests
parentcbed2931c9244daa2e1e8d4c0b13958f8e5e0148 (diff)
Update docs
Diffstat (limited to 'tests')
-rw-r--r--tests/testthat.R12
-rw-r--r--tests/testthat/test-rsc.R19
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/testthat.R b/tests/testthat.R
new file mode 100644
index 0000000..cfeb4a2
--- /dev/null
+++ b/tests/testthat.R
@@ -0,0 +1,12 @@
+# This file is part of the standard setup for testthat.
+# It is recommended that you do not modify it.
+#
+# Where should you do additional test configuration?
+# Learn more about the roles of various files in:
+# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
+# * https://testthat.r-lib.org/articles/special-files.html
+
+library(testthat)
+library(RSC)
+
+test_check("RSC")
diff --git a/tests/testthat/test-rsc.R b/tests/testthat/test-rsc.R
new file mode 100644
index 0000000..e392bb5
--- /dev/null
+++ b/tests/testthat/test-rsc.R
@@ -0,0 +1,19 @@
+test_that("rsc unchanged when weights = NULL", {
+ set.seed(1)
+ p <- 10
+ X <- matrix(rnorm(p * p), p)
+ cv <- rsc_cv(X, ncores = 1)
+ R1 <- rsc(cv)
+ R2 <- rsc(cv, weights = NULL)
+ expect_equal(R1, R2)
+})
+
+test_that("if given weights of all 1 of the right dimensions, rsc should be unchanged", {
+ set.seed(1)
+ p <- 10
+ X <- matrix(rnorm(p * p), p)
+ cv <- rsc_cv(X, ncores = 1)
+ R1 <- rsc(cv)
+ R2 <- rsc(cv, weights = matrix(data = 1, ncol = p, nrow = p))
+ expect_equal(R1, R2)
+})