@@ -23,30 +23,26 @@ type StringModule() =
2323
2424 [<Test>]
2525 member this.Concat () =
26- let e1 = String.concat null [ " foo" ]
27- Assert.AreEqual( " foo" , e1)
28-
29- let e2 = String.concat " " []
30- Assert.AreEqual( " " , e2)
31-
32- let e3 = String.concat " foo" []
33- Assert.AreEqual( " " , e3)
34-
35- let e4 = String.concat " " [ null ]
36- Assert.AreEqual( " " , e4)
37-
38- let e5 = String.concat " " [ " " ]
39- Assert.AreEqual( " " , e5)
40-
41- let e6 = String.concat " foo" [ " bar" ]
42- Assert.AreEqual( " bar" , e6)
43-
44- let e7 = String.concat " foo" [ " bav" ; " baz" ]
45- Assert.AreEqual( " bavfoobaz" , e7)
46-
47- let e8 = String.concat " foo" [ null ; " baz" ; null ; " bar" ]
48- Assert.AreEqual( " foobazfoofoobar" , e8)
49-
26+ /// This tests the three paths of String.concat w.r.t. array, list, seq
27+ let execTest f expected arg =
28+ let r1 = f ( List.toSeq arg)
29+ Assert.AreEqual( expected, r1)
30+
31+ let r2 = f ( List.toArray arg)
32+ Assert.AreEqual( expected, r2)
33+
34+ let r3 = f arg
35+ Assert.AreEqual( expected, r3)
36+
37+ do execTest ( String.concat null ) " foo" [ " foo" ]
38+ do execTest ( String.concat " " ) " " []
39+ do execTest ( String.concat " foo" ) " " []
40+ do execTest ( String.concat " " ) " " [ null ]
41+ do execTest ( String.concat " " ) " " [ " " ]
42+ do execTest ( String.concat " foo" ) " bar" [ " bar" ]
43+ do execTest ( String.concat " foo" ) " bavfoobaz" [ " bav" ; " baz" ]
44+ do execTest ( String.concat " foo" ) " foobazfoofoobar" [ null ; " baz" ; null ; " bar" ]
45+
5046 CheckThrowsArgumentNullException( fun () -> String.concat " foo" null |> ignore)
5147
5248 [<Test>]
0 commit comments