|
5 | 5 | void test_date_rfc2822__format_rfc2822_no_offset(void) |
6 | 6 | { |
7 | 7 | git_time t = {1397031663, 0}; |
8 | | - char buf[GIT_DATE_RFC2822_SZ]; |
| 8 | + git_str buf = GIT_STR_INIT; |
9 | 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); |
| 10 | + cl_git_pass(git_date_rfc2822_fmt(&buf, t.time, t.offset)); |
| 11 | + cl_assert_equal_s("Wed, 9 Apr 2014 08:21:03 +0000", buf.ptr); |
| 12 | + |
| 13 | + git_str_dispose(&buf); |
12 | 14 | } |
13 | 15 |
|
14 | 16 | void test_date_rfc2822__format_rfc2822_positive_offset(void) |
15 | 17 | { |
16 | 18 | git_time t = {1397031663, 120}; |
17 | | - char buf[GIT_DATE_RFC2822_SZ]; |
| 19 | + git_str buf = GIT_STR_INIT; |
| 20 | + |
| 21 | + cl_git_pass(git_date_rfc2822_fmt(&buf, t.time, t.offset)); |
| 22 | + cl_assert_equal_s("Wed, 9 Apr 2014 10:21:03 +0200", buf.ptr); |
18 | 23 |
|
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); |
| 24 | + git_str_dispose(&buf); |
21 | 25 | } |
22 | 26 |
|
23 | 27 | void test_date_rfc2822__format_rfc2822_negative_offset(void) |
24 | 28 | { |
25 | 29 | git_time t = {1397031663, -120}; |
26 | | - char buf[GIT_DATE_RFC2822_SZ]; |
| 30 | + git_str buf = GIT_STR_INIT; |
27 | 31 |
|
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]; |
| 32 | + cl_git_pass(git_date_rfc2822_fmt(&buf, t.time, t.offset)); |
| 33 | + cl_assert_equal_s("Wed, 9 Apr 2014 06:21:03 -0200", buf.ptr); |
37 | 34 |
|
38 | | - cl_git_fail(git_date_rfc2822_fmt(buf, sizeof(buf), &t)); |
| 35 | + git_str_dispose(&buf); |
39 | 36 | } |
40 | 37 |
|
0 commit comments