@@ -13,6 +13,9 @@ let testArrayNegInfinity = [|10000.;-0.1;14.;-10.;5.;Double.NegativeInfinity|]
1313
1414let testArrayEvenCountsInt = [| 10000 ;- 50 ; 14 ;- 9 |]
1515let testArrayOddCountsInt = [| 10000 ;- 50 ; 14 ;- 10 ; 5 |]
16+ let testArrayEmptyInt : int array = [||]
17+ let testArrayEmptyFloat : float array = [||]
18+ let testArrayEmptyDec : decimal array = [||]
1619
1720[<Tests>]
1821let medianTests =
@@ -33,12 +36,21 @@ let medianTests =
3336 let median = Array.median testArrayNegInfinity
3437 Expect.floatClose Accuracy.high median 2.45 " Median should be 2.45"
3538
36- testCase " testListEvenCountsInt " <| fun () ->
39+ testCase " testArrayEvenCountsInt " <| fun () ->
3740 let median = Array.median testArrayEvenCountsInt
3841 Expect.equal median 2 " Median should be 2"
39- testCase " testListOddCountsInt " <| fun () ->
42+ testCase " testArrayOddCountsInt " <| fun () ->
4043 let median = Array.median testArrayOddCountsInt
4144 Expect.equal median 5 " Median should be 5"
45+ testCase " testArrayEmptyFloat" <| fun () ->
46+ let median = Array.median testArrayEmptyFloat
47+ Expect.isTrue ( Ops.isNan median) " Median of empty float array should be nan"
48+ testCase " testArrayEmptyInt" <| fun () ->
49+ let median () = Array.median testArrayEmptyInt
50+ Expect.throws ( fun () -> median () |> ignore) " Median for empty non-float sequences is not defined"
51+ testCase " testArrayEmptyDec" <| fun () ->
52+ let median () = Array.median testArrayEmptyDec
53+ Expect.throws ( fun () -> median () |> ignore) " Median for empty non-float sequences is not defined"
4254 ]
4355
4456[<Tests>]
0 commit comments