|
1 |
| -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. |
| 1 | +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. |
2 | 2 |
|
3 | 3 | namespace FSharp.Core.UnitTests.Collections
|
4 | 4 |
|
@@ -156,15 +156,42 @@ type StringModule() =
|
156 | 156 |
|
157 | 157 | [<Test>]
|
158 | 158 | member this.Replicate() =
|
159 |
| - let e1 = String.replicate 0 "foo" |
| 159 | + let e1 = String.replicate 0 "Snickersnee" |
160 | 160 | Assert.AreEqual("", e1)
|
161 | 161 |
|
162 |
| - let e2 = String.replicate 2 "foo" |
163 |
| - Assert.AreEqual("foofoo", e2) |
| 162 | + let e2 = String.replicate 2 "Collywobbles, " |
| 163 | + Assert.AreEqual("Collywobbles, Collywobbles, ", e2) |
164 | 164 |
|
165 | 165 | let e3 = String.replicate 2 null
|
166 | 166 | Assert.AreEqual("", e3)
|
167 | 167 |
|
| 168 | + let e4 = String.replicate 300_000 "" |
| 169 | + Assert.AreEqual("", e4) |
| 170 | + |
| 171 | + let e5 = String.replicate 23 "天地玄黃,宇宙洪荒。" |
| 172 | + Assert.AreEqual(230 , e5.Length) |
| 173 | + Assert.AreEqual("天地玄黃,宇宙洪荒。天地玄黃,宇宙洪荒。", e5.Substring(0, 20)) |
| 174 | + |
| 175 | + // This tests the cut-off point for the O(log(n)) algorithm with a prime number |
| 176 | + let e6 = String.replicate 84673 "!!!" |
| 177 | + Assert.AreEqual(84673 * 3, e6.Length) |
| 178 | + |
| 179 | + // This tests the cut-off point for the O(log(n)) algorithm with a 2^x number |
| 180 | + let e7 = String.replicate 1024 "!!!" |
| 181 | + Assert.AreEqual(1024 * 3, e7.Length) |
| 182 | + |
| 183 | + let e8 = String.replicate 1 "What a wonderful world" |
| 184 | + Assert.AreEqual("What a wonderful world", e8) |
| 185 | + |
| 186 | + let e9 = String.replicate 3 "أضعت طريقي! أضعت طريقي" // means: I'm lost |
| 187 | + Assert.AreEqual("أضعت طريقي! أضعت طريقيأضعت طريقي! أضعت طريقيأضعت طريقي! أضعت طريقي", e9) |
| 188 | + |
| 189 | + let e10 = String.replicate 4 "㏖ ㏗ ℵ " |
| 190 | + Assert.AreEqual("㏖ ㏗ ℵ ㏖ ㏗ ℵ ㏖ ㏗ ℵ ㏖ ㏗ ℵ ", e10) |
| 191 | + |
| 192 | + let e11 = String.replicate 5 "5" |
| 193 | + Assert.AreEqual("55555", e11) |
| 194 | + |
168 | 195 | CheckThrowsArgumentException(fun () -> String.replicate -1 "foo" |> ignore)
|
169 | 196 |
|
170 | 197 | [<Test>]
|
|
0 commit comments