diff options
author | Jacques Germishuys <jacquesg@striata.com> | 2014-04-10 12:44:12 +0200 |
---|---|---|
committer | Jacques Germishuys <jacquesg@striata.com> | 2014-04-11 21:55:36 +0200 |
commit | 51297cadb32df3f7e1b1820034ff5a4ed6703668 (patch) | |
tree | 8e01b403931f8d17f6276d344f368828f19ef674 | |
parent | 8e14b47fd788ce5ae0d1a003a8fba17753eb7db5 (diff) | |
download | libgit2-51297cadb32df3f7e1b1820034ff5a4ed6703668.tar.gz |
Added RFC2822 date format test cases
-rw-r--r-- | tests/date/rfc2822.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/date/rfc2822.c b/tests/date/rfc2822.c new file mode 100644 index 000000000..eda475ac9 --- /dev/null +++ b/tests/date/rfc2822.c @@ -0,0 +1,40 @@ +#include "clar_libgit2.h" + +#include "util.h" + +void test_date_rfc2822__format_rfc2822_no_offset(void) +{ + git_time t = {1397031663, 0}; + char buf[GIT_DATE_RFC2822_SZ]; + + cl_git_pass(git__date_rfc2822_fmt(buf, sizeof(buf), &t)); + cl_assert(strcmp(buf, "Wed, 9 Apr 2014 08:21:03 +0000") == 0); +} + +void test_date_rfc2822__format_rfc2822_positive_offset(void) +{ + git_time t = {1397031663, 120}; + char buf[GIT_DATE_RFC2822_SZ]; + + cl_git_pass(git__date_rfc2822_fmt(buf, sizeof(buf), &t)); + cl_assert(strcmp(buf, "Wed, 9 Apr 2014 10:21:03 +0200") == 0); +} + +void test_date_rfc2822__format_rfc2822_negative_offset(void) +{ + git_time t = {1397031663, -120}; + char buf[GIT_DATE_RFC2822_SZ]; + + 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_fail(git__date_rfc2822_fmt(buf, sizeof(buf), &t)); +} + |