diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-18 12:36:25 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-19 06:31:32 -0500 |
commit | add30a838867820788c871c1d034fcf68c2ad12c (patch) | |
tree | 7266dc18143c766f6242c6dc05835ea5c2793746 /tests/date/rfc2822.c | |
parent | b2c40314c7c8ae4b645f776f04dfe06983ad8ba3 (diff) | |
download | libgit2-ethomson/date.tar.gz |
date: rfc2822 formatting uses a `git_buf` instead of a static stringethomson/date
Diffstat (limited to 'tests/date/rfc2822.c')
-rw-r--r-- | tests/date/rfc2822.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/tests/date/rfc2822.c b/tests/date/rfc2822.c index c94c8403f..b0bbcfce5 100644 --- a/tests/date/rfc2822.c +++ b/tests/date/rfc2822.c @@ -5,36 +5,33 @@ void test_date_rfc2822__format_rfc2822_no_offset(void) { git_time t = {1397031663, 0}; - char buf[GIT_DATE_RFC2822_SZ]; + git_str buf = GIT_STR_INIT; - cl_git_pass(git_date_rfc2822_fmt(buf, sizeof(buf), &t)); - cl_assert(strcmp(buf, "Wed, 9 Apr 2014 08:21:03 +0000") == 0); + cl_git_pass(git_date_rfc2822_fmt(&buf, t.time, t.offset)); + cl_assert_equal_s("Wed, 9 Apr 2014 08:21:03 +0000", buf.ptr); + + git_str_dispose(&buf); } void test_date_rfc2822__format_rfc2822_positive_offset(void) { git_time t = {1397031663, 120}; - char buf[GIT_DATE_RFC2822_SZ]; + git_str buf = GIT_STR_INIT; + + cl_git_pass(git_date_rfc2822_fmt(&buf, t.time, t.offset)); + cl_assert_equal_s("Wed, 9 Apr 2014 10:21:03 +0200", buf.ptr); - cl_git_pass(git_date_rfc2822_fmt(buf, sizeof(buf), &t)); - cl_assert(strcmp(buf, "Wed, 9 Apr 2014 10:21:03 +0200") == 0); + git_str_dispose(&buf); } void test_date_rfc2822__format_rfc2822_negative_offset(void) { git_time t = {1397031663, -120}; - char buf[GIT_DATE_RFC2822_SZ]; + git_str buf = GIT_STR_INIT; - cl_git_pass(git_date_rfc2822_fmt(buf, sizeof(buf), &t)); - cl_assert(strcmp(buf, "Wed, 9 Apr 2014 06:21:03 -0200") == 0); -} - -void test_date_rfc2822__format_rfc2822_buffer_too_small(void) -{ - /* "Wed, 10 Apr 2014 08:21:03 +0000" */ - git_time t = {1397031663 + 86400, 0}; - char buf[GIT_DATE_RFC2822_SZ-1]; + cl_git_pass(git_date_rfc2822_fmt(&buf, t.time, t.offset)); + cl_assert_equal_s("Wed, 9 Apr 2014 06:21:03 -0200", buf.ptr); - cl_git_fail(git_date_rfc2822_fmt(buf, sizeof(buf), &t)); + git_str_dispose(&buf); } |