4448df03a860bc71fea119e301ecc92f2785fc5e
[epclust.git] / epclust / tests / testthat / test-utils.R
1 context("utils functions")
2
3 test_that("Helper function to split indices work properly",
4 {
5 indices <- 1:400
6
7 # bigger nb_per_set than length(indices)
8 expect_equal(epclust:::.splitIndices(indices,500), list(indices))
9
10 # nb_per_set == length(indices)
11 expect_equal(epclust:::.splitIndices(indices,400), list(indices))
12
13 # length(indices) %% nb_per_set == 0
14 expect_equal(epclust:::.splitIndices(indices,200),
15 c( list(indices[1:200]), list(indices[201:400]) ))
16 expect_equal(epclust:::.splitIndices(indices,100),
17 c( list(indices[1:100]), list(indices[101:200]),
18 list(indices[201:300]), list(indices[301:400]) ))
19
20 # length(indices) / nb_per_set == 1, length(indices) %% nb_per_set == 100
21 expect_equal(epclust:::.splitIndices(indices,300), list(indices))
22 # length(indices) / nb_per_set == 2, length(indices) %% nb_per_set == 42
23 repartition <- epclust:::.splitIndices(indices,179)
24 expect_equal(length(repartition), 2)
25 expect_equal(length(repartition[[1]]), 179 + 21)
26 expect_equal(length(repartition[[1]]), 179 + 21)
27 })
28
29 test_that("curvesToContribs output correct results",
30 {
31 # curvesToContribs(...)
32 })