Skip to content

Commit

Permalink
Duration model test
Browse files Browse the repository at this point in the history
  • Loading branch information
seb231 committed Sep 5, 2019
1 parent fbc3460 commit 192d8a1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/cic/model_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,18 @@
(testing "returns range of year counts close to example"
(is (= (vec (distinct (map #(-> % first second) result)))
fuzzy-yrs)))))

(def duration-data {0 [[0 0 0][1 6 17][10 17 25][17 21 51][19 39 68][35 56 83][50 77 107][67 84 117][79 107 126][84 115 133][107 121 137][115 130 139][121 135 147][129 138 152][133 141 156][137 148 161][139 152 165][145 157 171][151 161 174][154 165 181][158 171 187][162 174 190][167 181 201][171 186 207][174 190 210][181 199 218][186 203 225][189 210 232][195 214 237][202 224 242][209 230 244][213 235 251][223 239 256][228 243 263][233 245 273][238 252 280][242 258 288][245 265 303][251 278 313][253 282 318][263 290 330][270 305 337][279 314 349][286 323 357][300 332 365][309 339 370][316 349 380][327 357 390][336 365 396][344 372 407][356 380 412][362 391 418][368 396 425][377 407 429][383 412 439][392 418 446][399 426 452][410 431 463][417 440 472][425 448 476][428 454 489][435 464 498][443 474 504][452 477 514][461 490 519][468 498 524][476 505 534][486 515 543][497 521 548][504 526 556][514 540 563][519 547 581][526 551 590][540 559 599][546 566 616][550 590 623][559 598 637][566 613 646][590 619 663][598 636 664][614 643 677][623 663 679][637 664 685][646 677 699][663 680 721][670 687 744][678 700 770][683 734 794][696 760 811][721 779 827][748 802 843][776 817 887][802 840 938][821 869 974][843 938 1037][897 974 1094][948 1072 1223][1033 1104 1343][1104 1320 1932][1343 1707 4433][6935 6935 6935]]})

(comment
"build a test around this:"
((duration-model duration-data) 0 (r/make-random 12)))

(deftest duration-model-test
(let [duration-model-0 (partial (duration-model duration-data) 0)
list-durations (reduce concat (reduce into [] (vals duration-data)))
minimum (apply min list-durations)
maximum (apply max list-durations)]
(testing "duration for age 0 always falls between min and max when randomly sampled 1000 times"
(is (every? #(and (>= % minimum) (<= % maximum))
(repeat 1000 (duration-model-0 (r/make-random (rand-int 10000)))))))))

0 comments on commit 192d8a1

Please sign in to comment.