X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=epclust%2Ftests%2Ftestthat%2Ftest-utils.R;fp=epclust%2Ftests%2Ftestthat%2Ftest-utils.R;h=4448df03a860bc71fea119e301ecc92f2785fc5e;hb=40f12a2f66d06fd77183ea02b996f5c66f90761c;hp=0000000000000000000000000000000000000000;hpb=a52836b23adb4bfa6722642ec6426fb7b5f39650;p=epclust.git diff --git a/epclust/tests/testthat/test-utils.R b/epclust/tests/testthat/test-utils.R new file mode 100644 index 0000000..4448df0 --- /dev/null +++ b/epclust/tests/testthat/test-utils.R @@ -0,0 +1,32 @@ +context("utils functions") + +test_that("Helper function to split indices work properly", +{ + indices <- 1:400 + + # bigger nb_per_set than length(indices) + expect_equal(epclust:::.splitIndices(indices,500), list(indices)) + + # nb_per_set == length(indices) + expect_equal(epclust:::.splitIndices(indices,400), list(indices)) + + # length(indices) %% nb_per_set == 0 + expect_equal(epclust:::.splitIndices(indices,200), + c( list(indices[1:200]), list(indices[201:400]) )) + expect_equal(epclust:::.splitIndices(indices,100), + c( list(indices[1:100]), list(indices[101:200]), + list(indices[201:300]), list(indices[301:400]) )) + + # length(indices) / nb_per_set == 1, length(indices) %% nb_per_set == 100 + expect_equal(epclust:::.splitIndices(indices,300), list(indices)) + # length(indices) / nb_per_set == 2, length(indices) %% nb_per_set == 42 + repartition <- epclust:::.splitIndices(indices,179) + expect_equal(length(repartition), 2) + expect_equal(length(repartition[[1]]), 179 + 21) + expect_equal(length(repartition[[1]]), 179 + 21) +}) + +test_that("curvesToContribs output correct results", +{ +# curvesToContribs(...) +})