-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathChapter_03_ex_1_Tests.fs
47 lines (34 loc) · 1.9 KB
/
Chapter_03_ex_1_Tests.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
46
47
module Chapter_03_ex_1_Tests
open System
open NUnit.Framework
open FsUnit
open Chapter_03_ex_1
[<TestFixture>]
type ``Chapter_03_Tests``() =
[<Test>]
member x.``3.1 triple - no custom compare``() =
(10, 10, "AM") < (10, 11, "AM") |> should equal true
(10, 10, "PM") < (10, 11, "AM") |> should equal true // counter-intuitive ;)
(10, 10, "AM") < (10, 10, "PM") |> should equal true
(10, 10, "PM") < (10, 11, "PM") |> should equal true
(11, 59, "AM") < (1, 15, "PM") |> should equal false // counter-intuitive
(11, 00, "AM") < (1, 15, "AM") |> should equal false
(11, 59, "AM") < (11, 59, "AM") |> should equal false
[<Test>]
member x.``3.1 triple - custom compare``() =
(10, 10, "AM") &< (10, 11, "AM") |> should equal true
(10, 10, "PM") &< (10, 11, "AM") |> should equal false
(10, 10, "AM") &< (10, 10, "PM") |> should equal true
(10, 10, "PM") &< (10, 11, "PM") |> should equal true
(11, 59, "AM") &< (1, 15, "PM") |> should equal true
(11, 00, "AM") &< (1, 15, "AM") |> should equal false
(11, 59, "AM") &< (11, 59, "AM") |> should equal false
[<Test>]
member x.``3.1 record``() =
{ AmPm = AM; Hour=10; Minute=10 } < { AmPm = AM; Hour=10; Minute=11 } |> should equal true
{ AmPm = PM; Hour=10; Minute=10 } < { AmPm = AM; Hour=10; Minute=11 } |> should equal false
{ AmPm = AM; Hour=10; Minute=10 } < { AmPm = PM; Hour=10; Minute=10 } |> should equal true
{ AmPm = PM; Hour=10; Minute=10 } < { AmPm = PM; Hour=10; Minute=11 } |> should equal true
{ AmPm = AM; Hour=11; Minute=59 } < { AmPm = PM; Hour=1; Minute=15 } |> should equal true
{ AmPm = AM; Hour=11; Minute=00 } < { AmPm = AM; Hour=1; Minute=15 } |> should equal false
{ AmPm = AM; Hour=11; Minute=59 } < { AmPm = AM; Hour=11; Minute=59 } |> should equal false