|
| 1 | + |
| 2 | +test_that("doubly constrained tested", { |
| 3 | + |
| 4 | + ## error datas |
| 5 | + error_dist <- cbind(cppSim::distance_test,1:ncol(cppSim::distance_test)) |
| 6 | + |
| 7 | + error_dist_neg <- cppSim::distance_test |
| 8 | + error_dist_neg[100,150] <- -1 |
| 9 | + |
| 10 | + error_flow_neg <- cppSim::flows_test |
| 11 | + error_flow_neg[543,57] <- -1 |
| 12 | + # errors |
| 13 | + testthat::expect_error({ |
| 14 | + cppSim::run_model(flows = cppSim::flows_test |
| 15 | + ,distance = error_dist) |
| 16 | + }) |
| 17 | + |
| 18 | + testthat::expect_error({ |
| 19 | + cppSim::run_model(flows = cppSim::flows_test |
| 20 | + ,distance = cppSim::distance_test |
| 21 | + ,beta = -1) |
| 22 | + }) |
| 23 | + |
| 24 | + testthat::expect_error({ |
| 25 | + cppSim::run_model(flows=cppSim::flows_test |
| 26 | + ,distance = error_dist_neg#cppSim::distance_test |
| 27 | + ) |
| 28 | + }) |
| 29 | + |
| 30 | + testthat::expect_error({ |
| 31 | + cppSim::run_model(flows= error_flow_neg |
| 32 | + ,distance = cppSim::distance_test |
| 33 | + ) |
| 34 | + }) |
| 35 | + |
| 36 | + |
| 37 | + #### Correct |
| 38 | + |
| 39 | + testthat::expect_type({ |
| 40 | + |
| 41 | + cppSim::run_model(flows = cppSim::flows_test |
| 42 | + ,distance = cppSim::distance_test) |
| 43 | + |
| 44 | + },"list") |
| 45 | + |
| 46 | +}) |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +test_that("singly constrained tested", { |
| 51 | + |
| 52 | + ## error datas |
| 53 | + error_dist <- cbind(cppSim::distance_test,1:ncol(cppSim::distance_test)) |
| 54 | + |
| 55 | + error_dist_neg <- cppSim::distance_test |
| 56 | + error_dist_neg[100,150] <- -1 |
| 57 | + |
| 58 | + orig_flow <- error_flow_neg <- apply(cppSim::flows_test,FUN = sum,MARGIN = 1) |
| 59 | + |
| 60 | + error_flow_neg[543] <- -1 |
| 61 | + |
| 62 | + # errors |
| 63 | + testthat::expect_error({ |
| 64 | + cppSim::run_model_single(flows = c(orig_flow,1,2) |
| 65 | + ,distance = error_dist) |
| 66 | + }) |
| 67 | + |
| 68 | + testthat::expect_error({ |
| 69 | + cppSim::run_model_single(flows = orig_flow |
| 70 | + ,distance = cppSim::distance_test |
| 71 | + ,beta = -1) |
| 72 | + }) |
| 73 | + |
| 74 | + testthat::expect_error({ |
| 75 | + cppSim::run_model_single(flows = orig_flow |
| 76 | + ,distance = error_dist_neg#cppSim::distance_test |
| 77 | + ) |
| 78 | + }) |
| 79 | + |
| 80 | + testthat::expect_error({ |
| 81 | + cppSim::run_model_single(flows = error_flow_neg |
| 82 | + ,distance = cppSim::distance_test |
| 83 | + ) |
| 84 | + }) |
| 85 | + |
| 86 | + #### Correct |
| 87 | + |
| 88 | + testthat::expect_type({ |
| 89 | + |
| 90 | + cppSim::run_model_single(flows = orig_flow |
| 91 | + ,distance = cppSim::distance_test) |
| 92 | + |
| 93 | + },"list") |
| 94 | + |
| 95 | +}) |
0 commit comments