Skip to content

Commit

Permalink
Fix issue #5
Browse files Browse the repository at this point in the history
  • Loading branch information
astrada committed Jun 23, 2012
1 parent 82c8215 commit d0413a3
Showing 1 changed file with 45 additions and 40 deletions.
85 changes: 45 additions & 40 deletions src/test/testDate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,74 @@ open OUnit

let test_to_string () =
let t = {
Netdate.year = 2011;
month = 10;
day = 14;
hour = 10;
minute = 30;
second = 0;
zone = 120;
week_day = -1 } 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
{ Netdate.year = 2011;
GapiDate.epoch with
Netdate.year = 2011;
month = 10;
day = 14;
hour = 10;
minute = 30;
second = 0;
zone = 120;
week_day = -1 }
} 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
{ Netdate.year = 2011;
month = 10;
day = 14;
hour = 10;
minute = 30;
second = 0;
zone = -120;
week_day = -1 }
{ 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
{ Netdate.year = 2011;
month = 10;
day = 14;
hour = 10;
minute = 30;
second = 0;
zone = 0;
week_day = -1 }
{ 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
{ Netdate.year = 2011;
month = 10;
day = 14;
hour = 0;
minute = 0;
second = 0;
zone = 0;
week_day = -1 }
{ GapiDate.epoch with
Netdate.year = 2011;
month = 10;
day = 14;
hour = 0;
minute = 0;
second = 0;
week_day = -1;
}
t

let suite = "Date test" >:::
Expand Down

0 comments on commit d0413a3

Please sign in to comment.