summaryrefslogtreecommitdiff
path: root/tests/libgit2/date/rfc2822.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libgit2/date/rfc2822.c')
-rw-r--r--tests/libgit2/date/rfc2822.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/libgit2/date/rfc2822.c b/tests/libgit2/date/rfc2822.c
new file mode 100644
index 000000000..b0bbcfce5
--- /dev/null
+++ b/tests/libgit2/date/rfc2822.c
@@ -0,0 +1,37 @@
+#include "clar_libgit2.h"
+
+#include "date.h"
+
+void test_date_rfc2822__format_rfc2822_no_offset(void)
+{
+ git_time t = {1397031663, 0};
+ 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 08:21:03 +0000", buf.ptr);
+
+ git_str_dispose(&buf);
+}
+
+void test_date_rfc2822__format_rfc2822_positive_offset(void)
+{
+ git_time t = {1397031663, 120};
+ 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);
+
+ git_str_dispose(&buf);
+}
+
+void test_date_rfc2822__format_rfc2822_negative_offset(void)
+{
+ git_time t = {1397031663, -120};
+ 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 06:21:03 -0200", buf.ptr);
+
+ git_str_dispose(&buf);
+}
+