Skip to content

Commit ef7b3ca

Browse files
committed
Duration model test
1 parent 9a5f4ba commit ef7b3ca

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/cic/model_test.clj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,14 @@
3535
(testing "returns range of year counts close to example"
3636
(is (= (vec (distinct (map #(-> % first second) result)))
3737
fuzzy-yrs)))))
38+
39+
(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]]})
40+
41+
(deftest duration-model-test
42+
(let [duration-model-0 (partial (duration-model duration-data) 0)
43+
list-durations (reduce concat (reduce into [] (vals duration-data)))
44+
minimum (apply min list-durations)
45+
maximum (apply max list-durations)]
46+
(testing "duration for age 0 always falls between min and max when randomly sampled 1000 times"
47+
(is (every? #(and (>= % minimum) (<= % maximum))
48+
(repeat 1000 (duration-model-0 (r/make-random (rand-int 10000)))))))))

0 commit comments

Comments
 (0)