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>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/tests/t04-commit.c b/tests/t04-commit.c
index 415017a..63d409c 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 ");