forked from astrada/gapi-ocaml
/
testDate.ml
81 lines (74 loc) · 1.94 KB
/
testDate.ml
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
open OUnit
let test_to_string () =
let t = {
GapiDate.epoch with
Netdate.year = 2011;
month = 10;
day = 14;
hour = 10;
minute = 30;
second = 0;
zone = 120;
} in
let s = GapiDate.to_string t in
assert_equal "2011-10-14T10:30:00.000+02:00" s
let test_of_string () =
let t = GapiDate.of_string "2011-10-14T10:30:00.000+02:00" in
assert_equal
{ GapiDate.epoch with
Netdate.year = 2011;
month = 10;
day = 14;
hour = 10;
minute = 30;
zone = 120;
week_day = -1;
}
t
let test_of_string_negative_offset () =
let t = GapiDate.of_string "2011-10-14T10:30:00.000-02:00" in
assert_equal
{ GapiDate.epoch with
Netdate.year = 2011;
month = 10;
day = 14;
hour = 10;
minute = 30;
zone = -120;
week_day = -1;
}
t
let test_of_string_utc () =
let t = GapiDate.of_string "2011-10-14T10:30:00.000Z" in
assert_equal
~printer:GapiDate.to_string
{ GapiDate.epoch with
Netdate.year = 2011;
month = 10;
day = 14;
hour = 10;
minute = 30;
second = 0;
week_day = -1;
}
t
let test_of_string_full_date () =
let t = GapiDate.of_string "2011-10-14" in
assert_equal
~printer:GapiDate.to_string
{ GapiDate.epoch with
Netdate.year = 2011;
month = 10;
day = 14;
hour = 0;
minute = 0;
second = 0;
week_day = -1;
}
t
let suite = "Date test" >:::
["test_to_string" >:: test_to_string;
"test_of_string" >:: test_of_string;
"test_of_string_negative_offset" >:: test_of_string_negative_offset;
"test_of_string_utc" >:: test_of_string_utc;
"test_of_string_full_date" >:: test_of_string_full_date]