Skip to content

Commit 21cd0b1

Browse files
committed
add tests prepared by AleksandraDabrowska
1 parent fd103cb commit 21cd0b1

6 files changed

+128
-0
lines changed

tests/testthat.R

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library(testthat)
2+
library(factorMerger)
3+
4+
test_check("factorMerger")

tests/testthat/testfactorManipulation.R

Whitespace-only changes.
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
library(factorMerger)
2+
3+
dfWithoutCovariates <- generateMultivariateSample(20,10)
4+
dfWithCovariates <- dfWithoutCovariates
5+
dfWithCovariates$covariates <- data.frame(runif(20), rnorm(20))
6+
7+
8+
context("Check mergeFactors() function")
9+
10+
test_that("Wrong input",{
11+
expect_error(mergeFactors())
12+
expect_error(mergeFactors(dfWithCovariates$response))
13+
expect_error(mergeFactors(dfWithCovariates$factor))
14+
})
15+
16+
test_that("Output format",{
17+
expect_is(mergeFactors(dfWithCovariates$response, dfWithCovariates$factor), "factorMerger")
18+
expect_is(mergeFactors(dfWithCovariates$response, dfWithCovariates$factor, method = "fast-adaptive"), "factorMerger")
19+
})
20+
21+
22+
context("Check groupStats() function")
23+
24+
test_that("Wrong input",{
25+
expect_error(groupsStats())
26+
expect_error(groupsStats(dfWithoutCovariates))
27+
})
28+
29+
test_that("Output format",{
30+
expect_is(groupsStats(mergeFactors(dfWithCovariates$response, dfWithCovariates$factor)), "data.frame")
31+
})
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
library(factorMerger)
2+
3+
dfWithoutCovariates <- generateMultivariateSample(20,10)
4+
merged <- mergeFactors(dfWithoutCovariates$response, dfWithoutCovariates$factor)
5+
6+
7+
context("Check cutTree() function")
8+
9+
test_that("Wrong input",{
10+
expect_error(cutTree())
11+
})
12+
13+
test_that("Output format",{
14+
expect_is(cutTree(merged), "factor")
15+
})
16+
17+
18+
19+
context("Check getOptimalPartition() function")
20+
21+
test_that("Wrong input",{
22+
expect_error(getOptimalPartition())
23+
})
24+
25+
test_that("Output format",{
26+
expect_is(getOptimalPartition(merged), "character")
27+
})
28+
29+
30+
31+
context("Check getOptimalPartitionDf() function")
32+
33+
test_that("Wrong input",{
34+
expect_error(getOptimalPartitionDf())
35+
})
36+
37+
test_that("Output format",{
38+
expect_is(getOptimalPartitionDf(merged), "data.frame")
39+
})
40+
41+

tests/testthat/teststatisticCalc.R

Whitespace-only changes.

tests/testthat/testvisualizations.R

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
library(factorMerger)
2+
3+
dfWithoutCovariates <- generateMultivariateSample(20,10)
4+
merged <- mergeFactors(dfWithoutCovariates$response, dfWithoutCovariates$factor)
5+
6+
7+
context("Check plot() function")
8+
9+
test_that("Wrong input",{
10+
expect_error(plot())
11+
})
12+
13+
test_that("Output format",{
14+
expect_is(plot(merged), "gg")
15+
expect_is(plot(merged), "ggplot")
16+
expect_is(plot(merged), "ggarrange")
17+
})
18+
19+
context("Check plotHeatmap() function")
20+
21+
test_that("Wrong input",{
22+
expect_error(plotHeatmap())
23+
})
24+
25+
test_that("Output format",{
26+
expect_is(plotHeatmap(merged, color=TRUE, clusterSplit=list("pvalue", "GIC")), "gg")
27+
expect_is(plotHeatmap(merged, color=TRUE, clusterSplit=list("pvalue", "GIC")), "ggplot")
28+
})
29+
30+
# context("Check plotProfile() function")
31+
#
32+
# test_that("Wrong input",{
33+
# expect_error(plotProfile())
34+
# })
35+
#
36+
# test_that("Output format",{
37+
# expect_is(plotProfile(merged, color=TRUE, clusterSplit=list("pvalue", "GIC")), "gg")
38+
# expect_is(plotProfile(merged, color=TRUE, clusterSplit=list("pvalue", "GIC")), "ggplot")
39+
# })
40+
41+
42+
# context("Check plotHMeansAndConfInt() function")
43+
#
44+
# test_that("Wrong input",{
45+
# expect_error(plotMeansAndConfInt())
46+
# })
47+
#
48+
# test_that("Output format",{
49+
# expect_is(plotMeansAndConfInt(merged, color=TRUE, clusterSplit=list("pvalue", "GIC")), "gg")
50+
# expect_is(plotMeansAndConfInt(merged, color=TRUE, clusterSplit=list("pvalue", "GIC")), "ggplot")
51+
# })
52+

0 commit comments

Comments
 (0)