diff options
author | schu <schu-github@schulog.org> | 2011-06-28 19:06:06 +0400 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-07-05 04:21:26 +0400 |
commit | 60caf0246538f26ea867302021747a0f7eae0cda (patch) | |
tree | 218d54ef8b696dd0dd33ace175f8472d0198042b /tests | |
parent | 8b2c913acbb9848ffc9c0c1c39cb7a40ee5e710f (diff) |
t04-commit: add tests for git_signature__parse
git_signature__parse used to be very strict about what's a well-formed
signature. Add tests checking git_signature__parse can stick with
"unexpected" signatures (IOW no author name and / or no email, etc).
Signed-off-by: schu <schu-github@schulog.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/t04-commit.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/t04-commit.c b/tests/t04-commit.c index 415017aba..63d409ca3 100644 --- a/tests/t04-commit.c +++ b/tests/t04-commit.c @@ -241,6 +241,78 @@ BEGIN_TEST(parse1, "parse the signature line in a commit") 123456, -60); + /* Parse a signature without an author field */ + TEST_SIGNATURE_PASS( + "committer <tanoku@gmail.com> 123456 -0100 \n", + "committer ", + "", + "tanoku@gmail.com", + 123456, + -60); + + /* Parse a signature without an author field */ + TEST_SIGNATURE_PASS( + "committer <tanoku@gmail.com> 123456 -0100 \n", + "committer ", + "", + "tanoku@gmail.com", + 123456, + -60); + + /* Parse a signature with an empty author field */ + TEST_SIGNATURE_PASS( + "committer <tanoku@gmail.com> 123456 -0100 \n", + "committer ", + " ", + "tanoku@gmail.com", + 123456, + -60); + + /* Parse a signature with an empty email field */ + TEST_SIGNATURE_PASS( + "committer Vicent Marti <> 123456 -0100 \n", + "committer ", + "Vicent Marti", + "", + 123456, + -60); + + /* Parse a signature with an empty email field */ + TEST_SIGNATURE_PASS( + "committer Vicent Marti < > 123456 -0100 \n", + "committer ", + "Vicent Marti", + " ", + 123456, + -60); + + /* Parse a signature with empty name and email */ + TEST_SIGNATURE_PASS( + "committer <> 123456 -0100 \n", + "committer ", + "", + "", + 123456, + -60); + + /* Parse a signature with empty name and email */ + TEST_SIGNATURE_PASS( + "committer < > 123456 -0100 \n", + "committer ", + "", + " ", + 123456, + -60); + + /* Parse an obviously invalid signature */ + TEST_SIGNATURE_PASS( + "committer foo<@bar> 123456 -0100 \n", + "committer ", + "fo", + "@bar", + 123456, + -60); + TEST_SIGNATURE_FAIL( "committer Vicent Marti <tanoku@gmail.com> 123456 -1500 \n", "committer "); |