diff options
| author | Yoichi Nakayama <yoichi.nakayama@gmail.com> | 2021-10-22 07:54:12 +0900 |
|---|---|---|
| committer | Yoichi Nakayama <yoichi.nakayama@gmail.com> | 2021-10-22 07:54:12 +0900 |
| commit | 6c0d5366d9a9d24c76c1ca444a592111a1b2bdc3 (patch) | |
| tree | f460158fa1829d0d9ef8747380dccb22c2d51ed0 /tests | |
| parent | 776a6a8e5f8e258d31aded73c0ce38df6ac7bdc4 (diff) | |
| download | libgit2-6c0d5366d9a9d24c76c1ca444a592111a1b2bdc3.tar.gz | |
Cause error when date parsing is failed
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/date/date.c | 7 | ||||
| -rw-r--r-- | tests/refs/revparse.c | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/date/date.c b/tests/date/date.c index 88881d1e1..ae787c0d3 100644 --- a/tests/date/date.c +++ b/tests/date/date.c @@ -13,3 +13,10 @@ void test_date_date__overflow(void) cl_assert(d2038 < d2039); #endif } + +void test_date_date__invalid_date(void) +{ + git_time_t d; + cl_git_fail(git__date_parse(&d, "")); + cl_git_fail(git__date_parse(&d, "NEITHER_INTEGER_NOR_DATETIME")); +} diff --git a/tests/refs/revparse.c b/tests/refs/revparse.c index d6ec802e8..8d3a7e057 100644 --- a/tests/refs/revparse.c +++ b/tests/refs/revparse.c @@ -460,6 +460,19 @@ void test_refs_revparse__date(void) test_object("with-empty-log@{2 days ago}", NULL); } +void test_refs_revparse__invalid_date(void) +{ + /* + * $ git rev-parse HEAD@{} -- + * fatal: bad revision 'HEAD@{}' + * + * $ git rev-parse HEAD@{NEITHER_INTEGER_NOR_DATETIME} -- + * fatal: bad revision 'HEAD@{NEITHER_INTEGER_NOR_DATETIME}' + */ + test_object("HEAD@{}", NULL); + test_object("HEAD@{NEITHER_INTEGER_NOR_DATETIME}", NULL); +} + void test_refs_revparse__colon(void) { assert_invalid_single_spec(":/"); |
