Skip to content

Commit fa86dfb

Browse files
committed
Spec for calculateMedianIncomeIntervals method of ReportUtil
1 parent 2d6658e commit fa86dfb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

publication/src/test/scala/hmda/publication/reports/util/ReportUtilSpec.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,17 @@ class ReportUtilSpec extends AsyncWordSpec with MustMatchers {
1818
}
1919
}
2020

21+
"calculateMedianIncomeIntervals" must {
22+
"get median income info for given fips, convert to thousands" in {
23+
calculateMedianIncomeIntervals(10380)(2) mustBe 18.267
24+
calculateMedianIncomeIntervals(26980)(2) mustBe 81.027
25+
calculateMedianIncomeIntervals(41100)(2) mustBe 58.145
26+
}
27+
"return array of 50%, 80%, 100%, and 120% levels of median income (in thousands)" in {
28+
def roundTo3(v: Double) = BigDecimal(v).setScale(3, BigDecimal.RoundingMode.HALF_UP).toDouble
29+
calculateMedianIncomeIntervals(26980) mustBe Array(40.5135, 64.8216, 81.027, 97.2324)
30+
calculateMedianIncomeIntervals(41100).map(roundTo3) mustBe Array(29.073, 46.516, 58.145, 69.774)
31+
}
32+
}
33+
2134
}

0 commit comments

Comments
 (0)