]> git.proxmox.com Git - libgit2.git/blob - tests/date/rfc2822.c
eda475ac98098c41c1b3e5f0d659b17134ce86e8
[libgit2.git] / tests / date / rfc2822.c
1 #include "clar_libgit2.h"
2
3 #include "util.h"
4
5 void test_date_rfc2822__format_rfc2822_no_offset(void)
6 {
7 git_time t = {1397031663, 0};
8 char buf[GIT_DATE_RFC2822_SZ];
9
10 cl_git_pass(git__date_rfc2822_fmt(buf, sizeof(buf), &t));
11 cl_assert(strcmp(buf, "Wed, 9 Apr 2014 08:21:03 +0000") == 0);
12 }
13
14 void test_date_rfc2822__format_rfc2822_positive_offset(void)
15 {
16 git_time t = {1397031663, 120};
17 char buf[GIT_DATE_RFC2822_SZ];
18
19 cl_git_pass(git__date_rfc2822_fmt(buf, sizeof(buf), &t));
20 cl_assert(strcmp(buf, "Wed, 9 Apr 2014 10:21:03 +0200") == 0);
21 }
22
23 void test_date_rfc2822__format_rfc2822_negative_offset(void)
24 {
25 git_time t = {1397031663, -120};
26 char buf[GIT_DATE_RFC2822_SZ];
27
28 cl_git_pass(git__date_rfc2822_fmt(buf, sizeof(buf), &t));
29 cl_assert(strcmp(buf, "Wed, 9 Apr 2014 06:21:03 -0200") == 0);
30 }
31
32 void test_date_rfc2822__format_rfc2822_buffer_too_small(void)
33 {
34 // "Wed, 10 Apr 2014 08:21:03 +0000"
35 git_time t = {1397031663 + 86400, 0};
36 char buf[GIT_DATE_RFC2822_SZ-1];
37
38 cl_git_fail(git__date_rfc2822_fmt(buf, sizeof(buf), &t));
39 }
40