-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathBinarySearchTests.fs
45 lines (40 loc) · 1.09 KB
/
BinarySearchTests.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
namespace Algorithms.Tests.Search
open Microsoft.VisualStudio.TestTools.UnitTesting
open Algorithms.Search
[<TestClass>]
type BinarySearchTests() =
let data0 =
[| -2147483468
-10
-2
-1
0
1
2
10
20
20
2147483467 |]
[<TestMethod>]
[<DataRow(-2147483468, 0)>]
[<DataRow(-10, 1)>]
[<DataRow(-2, 2)>]
[<DataRow(-1, 3)>]
[<DataRow(0, 4)>]
[<DataRow(1, 5)>]
[<DataRow(2, 6)>]
[<DataRow(10, 7)>]
[<DataRow(2147483467, 10)>]
member this.Data0_Exists(num: int, expected: int) =
let actual = BinarySearch.findIndex num data0
Assert.AreEqual(expected, actual)
[<TestMethod>]
[<DataRow(20)>]
member this.Data0_Duplicates(num: int) =
let actual = BinarySearch.findIndex num data0
Assert.IsTrue(actual = 8 || actual = 9)
[<TestMethod>]
[<DataRow(5, -1)>]
member this.Data0_None(num: int, expected: int) =
let actual = BinarySearch.findIndex num data0
Assert.AreEqual(expected, actual)