Slightly enhanced the readability of some reference related tests.
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
diff --git a/tests/t10-refs.c b/tests/t10-refs.c
index baeb888..a5e9a33 100644
--- a/tests/t10-refs.c
+++ b/tests/t10-refs.c
@@ -318,63 +318,67 @@ static int ensure_refname_normalized(int is_oid_ref, const char *input_refname,
return error;
}
+#define OID_REF 1
+#define SYM_REF 0
+
BEGIN_TEST("normalizeref", normalize_object_id_ref)
- must_fail(ensure_refname_normalized(1, "a", NULL));
- must_fail(ensure_refname_normalized(1, "", NULL));
- must_fail(ensure_refname_normalized(1, "refs/heads/a/", NULL));
- must_fail(ensure_refname_normalized(1, "refs/heads/a.", NULL));
- must_fail(ensure_refname_normalized(1, "refs/heads/a.lock", NULL));
- must_fail(ensure_refname_normalized(1, "refs/dummy/a", NULL));
- must_pass(ensure_refname_normalized(1, "refs/tags/a", "refs/tags/a"));
- must_pass(ensure_refname_normalized(1, "refs/heads/a/b", "refs/heads/a/b"));
- must_pass(ensure_refname_normalized(1, "refs/heads/a./b", "refs/heads/a./b"));
- must_fail(ensure_refname_normalized(1, "refs/heads/foo?bar", NULL));
- must_fail(ensure_refname_normalized(1, "refs/heads\foo", NULL));
- must_pass(ensure_refname_normalized(1, "refs/heads/v@ation", "refs/heads/v@ation"));
- must_pass(ensure_refname_normalized(1, "refs///heads///a", "refs/heads/a"));
- must_fail(ensure_refname_normalized(1, "refs/heads/.a/b", NULL));
- must_fail(ensure_refname_normalized(1, "refs/heads/foo/../bar", NULL));
- must_fail(ensure_refname_normalized(1, "refs/heads/foo..bar", NULL));
- must_fail(ensure_refname_normalized(1, "refs/heads/./foo", NULL));
- must_fail(ensure_refname_normalized(1, "refs/heads/v@{ation", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "a", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads/a/", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads/a.", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads/a.lock", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/dummy/a", NULL));
+ must_pass(ensure_refname_normalized(OID_REF, "refs/tags/a", "refs/tags/a"));
+ must_pass(ensure_refname_normalized(OID_REF, "refs/heads/a/b", "refs/heads/a/b"));
+ must_pass(ensure_refname_normalized(OID_REF, "refs/heads/a./b", "refs/heads/a./b"));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads/foo?bar", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads\foo", NULL));
+ must_pass(ensure_refname_normalized(OID_REF, "refs/heads/v@ation", "refs/heads/v@ation"));
+ must_pass(ensure_refname_normalized(OID_REF, "refs///heads///a", "refs/heads/a"));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads/.a/b", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads/foo/../bar", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads/foo..bar", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads/./foo", NULL));
+ must_fail(ensure_refname_normalized(OID_REF, "refs/heads/v@{ation", NULL));
END_TEST
BEGIN_TEST("normalizeref", normalize_symbolic_ref)
- must_pass(ensure_refname_normalized(0, "a", "a"));
- must_pass(ensure_refname_normalized(0, "a/b", "a/b"));
- must_pass(ensure_refname_normalized(0, "refs///heads///a", "refs/heads/a"));
- must_fail(ensure_refname_normalized(0, "", NULL));
- must_fail(ensure_refname_normalized(0, "heads\foo", NULL));
+ must_pass(ensure_refname_normalized(SYM_REF, "a", "a"));
+ must_pass(ensure_refname_normalized(SYM_REF, "a/b", "a/b"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs///heads///a", "refs/heads/a"));
+ must_fail(ensure_refname_normalized(SYM_REF, "", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "heads\foo", NULL));
END_TEST
/* Ported from JGit, BSD licence. See https://github.com/spearce/JGit/commit/e4bf8f6957bbb29362575d641d1e77a02d906739 */
BEGIN_TEST("normalizeref", jgit_tests)
/* EmptyString */
- must_fail(ensure_refname_normalized(0, "", NULL));
- must_fail(ensure_refname_normalized(0, "/", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "/", NULL));
/* MustHaveTwoComponents */
- must_fail(ensure_refname_normalized(1, "master", NULL));
- must_pass(ensure_refname_normalized(0, "heads/master", "heads/master"));
+ must_fail(ensure_refname_normalized(OID_REF, "master", NULL));
+ must_pass(ensure_refname_normalized(SYM_REF, "heads/master", "heads/master"));
/* ValidHead */
- must_pass(ensure_refname_normalized(0, "refs/heads/master", "refs/heads/master"));
- must_pass(ensure_refname_normalized(0, "refs/heads/pu", "refs/heads/pu"));
- must_pass(ensure_refname_normalized(0, "refs/heads/z", "refs/heads/z"));
- must_pass(ensure_refname_normalized(0, "refs/heads/FoO", "refs/heads/FoO"));
+
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/master", "refs/heads/master"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/pu", "refs/heads/pu"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/z", "refs/heads/z"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/FoO", "refs/heads/FoO"));
/* ValidTag */
- must_pass(ensure_refname_normalized(0, "refs/tags/v1.0", "refs/tags/v1.0"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/tags/v1.0", "refs/tags/v1.0"));
/* NoLockSuffix */
- must_fail(ensure_refname_normalized(0, "refs/heads/master.lock", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master.lock", NULL));
/* NoDirectorySuffix */
- must_fail(ensure_refname_normalized(0, "refs/heads/master/", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master/", NULL));
/* NoSpace */
- must_fail(ensure_refname_normalized(0, "refs/heads/i haz space", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/i haz space", NULL));
/* NoAsciiControlCharacters */
{
@@ -385,91 +389,91 @@ BEGIN_TEST("normalizeref", jgit_tests)
strncpy(buffer + 15, (const char *)&c, 1);
strncpy(buffer + 16, "er", 2);
buffer[18 - 1] = '\0';
- must_fail(ensure_refname_normalized(0, buffer, NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, buffer, NULL));
}
}
/* NoBareDot */
- must_fail(ensure_refname_normalized(0, "refs/heads/.", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/..", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/./master", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/../master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/.", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/..", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/./master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/../master", NULL));
/* NoLeadingOrTrailingDot */
- must_fail(ensure_refname_normalized(0, ".", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/.bar", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/..bar", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/bar.", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, ".", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/.bar", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/..bar", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/bar.", NULL));
/* ContainsDot */
- must_pass(ensure_refname_normalized(0, "refs/heads/m.a.s.t.e.r", "refs/heads/m.a.s.t.e.r"));
- must_fail(ensure_refname_normalized(0, "refs/heads/master..pu", NULL));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/m.a.s.t.e.r", "refs/heads/m.a.s.t.e.r"));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master..pu", NULL));
/* NoMagicRefCharacters */
- must_fail(ensure_refname_normalized(0, "refs/heads/master^", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/^master", NULL));
- must_fail(ensure_refname_normalized(0, "^refs/heads/master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master^", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/^master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "^refs/heads/master", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/master~", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/~master", NULL));
- must_fail(ensure_refname_normalized(0, "~refs/heads/master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master~", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/~master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "~refs/heads/master", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/master:", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/:master", NULL));
- must_fail(ensure_refname_normalized(0, ":refs/heads/master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master:", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/:master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, ":refs/heads/master", NULL));
/* ShellGlob */
- must_fail(ensure_refname_normalized(0, "refs/heads/master?", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/?master", NULL));
- must_fail(ensure_refname_normalized(0, "?refs/heads/master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master?", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/?master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "?refs/heads/master", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/master[", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/[master", NULL));
- must_fail(ensure_refname_normalized(0, "[refs/heads/master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master[", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/[master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "[refs/heads/master", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/master*", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/*master", NULL));
- must_fail(ensure_refname_normalized(0, "*refs/heads/master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master*", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/*master", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "*refs/heads/master", NULL));
/* ValidSpecialCharacters */
- must_pass(ensure_refname_normalized(0, "refs/heads/!", "refs/heads/!"));
- must_pass(ensure_refname_normalized(0, "refs/heads/\"", "refs/heads/\""));
- must_pass(ensure_refname_normalized(0, "refs/heads/#", "refs/heads/#"));
- must_pass(ensure_refname_normalized(0, "refs/heads/$", "refs/heads/$"));
- must_pass(ensure_refname_normalized(0, "refs/heads/%", "refs/heads/%"));
- must_pass(ensure_refname_normalized(0, "refs/heads/&", "refs/heads/&"));
- must_pass(ensure_refname_normalized(0, "refs/heads/'", "refs/heads/'"));
- must_pass(ensure_refname_normalized(0, "refs/heads/(", "refs/heads/("));
- must_pass(ensure_refname_normalized(0, "refs/heads/)", "refs/heads/)"));
- must_pass(ensure_refname_normalized(0, "refs/heads/+", "refs/heads/+"));
- must_pass(ensure_refname_normalized(0, "refs/heads/,", "refs/heads/,"));
- must_pass(ensure_refname_normalized(0, "refs/heads/-", "refs/heads/-"));
- must_pass(ensure_refname_normalized(0, "refs/heads/;", "refs/heads/;"));
- must_pass(ensure_refname_normalized(0, "refs/heads/<", "refs/heads/<"));
- must_pass(ensure_refname_normalized(0, "refs/heads/=", "refs/heads/="));
- must_pass(ensure_refname_normalized(0, "refs/heads/>", "refs/heads/>"));
- must_pass(ensure_refname_normalized(0, "refs/heads/@", "refs/heads/@"));
- must_pass(ensure_refname_normalized(0, "refs/heads/]", "refs/heads/]"));
- must_pass(ensure_refname_normalized(0, "refs/heads/_", "refs/heads/_"));
- must_pass(ensure_refname_normalized(0, "refs/heads/`", "refs/heads/`"));
- must_pass(ensure_refname_normalized(0, "refs/heads/{", "refs/heads/{"));
- must_pass(ensure_refname_normalized(0, "refs/heads/|", "refs/heads/|"));
- must_pass(ensure_refname_normalized(0, "refs/heads/}", "refs/heads/}"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/!", "refs/heads/!"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/\"", "refs/heads/\""));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/#", "refs/heads/#"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/$", "refs/heads/$"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/%", "refs/heads/%"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/&", "refs/heads/&"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/'", "refs/heads/'"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/(", "refs/heads/("));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/)", "refs/heads/)"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/+", "refs/heads/+"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/,", "refs/heads/,"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/-", "refs/heads/-"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/;", "refs/heads/;"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/<", "refs/heads/<"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/=", "refs/heads/="));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/>", "refs/heads/>"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/@", "refs/heads/@"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/]", "refs/heads/]"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/_", "refs/heads/_"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/`", "refs/heads/`"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/{", "refs/heads/{"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/|", "refs/heads/|"));
+ must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/}", "refs/heads/}"));
// This is valid on UNIX, but not on Windows
// hence we make in invalid due to non-portability
//
- must_fail(ensure_refname_normalized(0, "refs/heads/\\", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/\\", NULL));
/* UnicodeNames */
/*
* Currently this fails.
- * must_pass(ensure_refname_normalized(GIT_REF_ANY, "refs/heads/\u00e5ngstr\u00f6m", "refs/heads/\u00e5ngstr\u00f6m"));
+ * must_pass(ensure_refname_normalized(SYM_REF, "refs/heads/\u00e5ngstr\u00f6m", "refs/heads/\u00e5ngstr\u00f6m"));
*/
/* RefLogQueryIsValidRef */
- must_fail(ensure_refname_normalized(0, "refs/heads/master@{1}", NULL));
- must_fail(ensure_refname_normalized(0, "refs/heads/master@{1.hour.ago}", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master@{1}", NULL));
+ must_fail(ensure_refname_normalized(SYM_REF, "refs/heads/master@{1.hour.ago}", NULL));
END_TEST
git_testsuite *libgit2_suite_refs(void)