Add a little more to the svn_rangelist_intersect test to test the
[svn.git] / subversion / tests / libsvn_subr / translate-test.c
blob0f5985176d219d43e5a97010c77b84a4f2ad759c
1 /*
2 * translate-test.c -- test the eol and keyword translation subroutine
4 * ====================================================================
5 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
21 /* Advice to those adding new tests to this file:
22 * ==============================================
24 * Read the doc string for substitute_and_verify(), then read the
25 * test functions themselves -- they're small, and they'll be very
26 * easy to understand once you know substitute_and_verify().
31 #include <stdio.h>
32 #include <string.h>
33 #include <apr_general.h>
34 #include <apr_file_io.h>
35 #include "svn_pools.h"
36 #include "svn_subst.h"
38 #include "../svn_test.h"
41 /*** Helpers ***/
43 /* (Almost) all the tests share the same test data. */
44 const char *lines[] =
46 "Line 1: fairly boring subst test data... blah blah",
47 "Line 2: fairly boring subst test data... blah blah.",
48 "Line 3: Valid $LastChangedRevision$, started unexpanded.",
49 "Line 4: fairly boring subst test data... blah blah.",
50 "Line 5: Valid $Rev$, started unexpanded.",
51 "Line 6: fairly boring subst test data... blah blah.",
52 "Line 7: fairly boring subst test data... blah blah.",
53 "Line 8: Valid $LastChangedBy$, started unexpanded.",
54 "Line 9: Valid $Author$, started unexpanded.",
55 "Line 10: fairly boring subst test data... blah blah.",
56 "Line 11: fairly boring subst test data... blah blah.",
57 "Line 12: Valid $LastChangedDate$, started unexpanded.",
58 "Line 13: Valid $Date$, started unexpanded.",
59 "Line 14: fairly boring subst test data... blah blah.",
60 "Line 15: fairly boring subst test data... blah blah.",
61 "Line 16: Valid $HeadURL$, started unexpanded.",
62 "Line 17: Valid $URL$, started unexpanded.",
63 "Line 18: fairly boring subst test data... blah blah.",
64 "Line 19: Invalid expanded keyword spanning two lines: $Author: ",
65 /* The idea here is that, were it not broken across two lines,
66 "$Author: Line 20: jrandom$" would be a valid if odd, keyword. */
67 "Line 20: jrandom$ remainder of invalid keyword spanning two lines.",
68 "Line 21: fairly boring subst test data... blah blah.",
69 "Line 22: an unknown keyword $LastChangedSocks$.",
70 "Line 23: fairly boring subst test data... blah blah.",
71 /* In line 24, the third dollar sign terminates the first, and the
72 fourth should therefore remain a literal dollar sign. */
73 "Line 24: keyword in a keyword: $Author: $Date$ $",
74 "Line 25: fairly boring subst test data... blah blah.",
75 "Line 26: Emptily expanded keyword $Rev: $.",
76 "Line 27: fairly boring subst test data... blah blah.",
77 "Line 28: fairly boring subst test data... blah blah.",
78 "Line 29: Valid $LastChangedRevision: 1729 $, started expanded.",
79 "Line 30: Valid $Rev: 1729 $, started expanded.",
80 "Line 31: fairly boring subst test data... blah blah.",
81 "Line 32: fairly boring subst test data... blah blah.",
82 "Line 33: Valid $LastChangedDate: 2002-01-01 $, started expanded.",
83 "Line 34: Valid $Date: 2002-01-01 $, started expanded.",
84 "Line 35: fairly boring subst test data... blah blah.",
85 "Line 36: fairly boring subst test data... blah blah.",
86 "Line 37: Valid $LastChangedBy: jrandom $, started expanded.",
87 "Line 38: Valid $Author: jrandom $, started expanded.",
88 "Line 39: fairly boring subst test data... blah blah.",
89 "Line 40: fairly boring subst test data... blah blah.",
90 "Line 41: Valid $HeadURL: http://tomato/mauve $, started expanded.",
91 "Line 42: Valid $URL: http://tomato/mauve $, started expanded.",
92 "Line 43: fairly boring subst test data... blah blah.",
93 "Line 44: fairly boring subst test data... blah blah.",
94 "Line 45: Invalid $LastChangedRevisionWithSuffix$, started unexpanded.",
95 "Line 46: Empty $Author:$, started expanded.",
96 "Line 47: fairly boring subst test data... blah blah.",
97 "Line 48: Two keywords back to back: $Author$$Rev$.",
98 "Line 49: One keyword, one not, back to back: $Author$Rev$.",
99 "Line 50: a series of dollar signs $$$$$$$$$$$$$$$$$$$$$$$$$$$$.",
100 "Line 51: same, but with embedded keyword $$$$$$$$Date$$$$$$$$$$.",
101 "Line 52: same, with expanded, empty keyword $$$$$$Date: $$$$$$.",
102 "Line 53: $This is a lengthy line designed to test a bug that was "
103 "reported about keyword expansion. The problem was that a line "
104 "had more than SVN_KEYWORD_MAX_LEN (255 at the time) characters "
105 "after an initial dollar sign, which triggered a buglet in our "
106 "svn_subst_copy_and_translate() function and resulted in, in some cases "
107 "a SEGFAULT, and in others a filthy corrupt commit. ",
108 "", /* Lines 54-69 are blank to test consecutive newlines */
124 "$Author$Rev$.", /* Line 70-73 test places where '$' abuts a newline. */
125 ".$veR$Author$",
126 "$",
127 "$$",
128 /* Line 74-75 test for keywords containing '$', issue #1780 */
129 "Line 74: Valid $Author: jran$dom $, started expanded.",
130 "Line 75: Valid $URL: http://tomato/mau$ve $, started expanded.",
131 /* Line 76-78 tests for a string with an unknown keyword of 252-254 bytes
132 long */
133 "$ "
136 " $$",
137 "$ "
140 " $$",
141 "$ "
144 " $$",
145 /* Testing border cases, line 79-82 test for valid keywords, keywords on
146 line 83-84 are too long */
147 "Line 79: Valid $Author: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
148 "aaaaaaaaaaaaa$aaaaaaaaaaaaaaaaaaaaaa$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
149 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
150 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa $, started expanded.",
151 "Line 80: Valid $Author: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$aaaaaaaaaaaaaaa"
152 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$aaaaaaaaaaaaaaaaaa"
153 "aaaaaaa$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
154 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$aaaaaaa $, started "
155 "expanded.",
156 /* keyword from first dollar sign to last = 254 chars */
157 "Line 81: Valid $Author: aaaaaaaaaaaaaaaaaaaa$aaaaaaaaaaaaaaaaaaaaaaaaaaa"
158 "aaaaaaaaaaaaa$aaaaaaaaaaaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
159 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaa"
160 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$$aaaaaa$$$ $, started "
161 "expanded.",
162 /* keyword from first dollar sign to last = 255 chars */
163 "Line 82: Valid $Author: aaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
164 "aaaaaaaaaaaaaaaaaaaaaaaaaa$$$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
165 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaa"
166 "aaaaaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$$$ $, started "
167 "expanded.",
168 /* keyword from first dollar sign to last = 256 chars */
169 "Line 83: Invalid $Author: aaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
170 "aaaaaaaaaaaaaaaaaaaaaaaaaa$$$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
171 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaa"
172 "aaaaaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$$$ $, started "
173 "expanded.",
174 "Line 84: Invalid $Author: aaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
175 "aaaaaaaaaaaaaaaaaaaaaaaaaa$$$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
176 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaa"
177 "aaaaaaaaaaaaaa$$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$$$ $, started "
178 "expanded.",
179 "Line 85: end of subst test data."
183 /* Return a randomly selected eol sequence. */
184 static const char *
185 random_eol_marker(void)
187 /* Select a random eol marker from this set. */
188 static int seeded = 0;
190 /* ### todo: allowing '\r' to be in this list of possible random
191 eol_markers causes problems for the current testing framework
192 which expects a 1:1 ratio of input-line-count to output-line-count.
193 Problems occur when there are two consecutive line ending markers
194 where the first is '\r' and the second is '\n' -- our
195 translation routine reads that as a single '\r\n' which throws
196 off the linecount on the output side, and fouls up substitute_and_verify.
198 const char *eol_markers[] = { "\n", "\r\n" };
200 if (! seeded)
202 srand(1729); /* we want errors to be reproducible */
203 seeded = 1;
206 return eol_markers[rand()
207 % ((sizeof(eol_markers)) / (sizeof(*eol_markers)))];
211 /* Create FNAME with global `lines' as initial data. Use EOL_STR as
212 * the end-of-line marker between lines, or if EOL_STR is NULL, choose
213 * a random marker at each opportunity. Use POOL for any temporary
214 * allocation.
216 static svn_error_t *
217 create_file(const char *fname, const char *eol_str, apr_pool_t *pool)
219 apr_status_t apr_err;
220 apr_file_t *f;
221 apr_size_t i, j;
223 apr_err = apr_file_open(&f, fname,
224 (APR_WRITE | APR_CREATE | APR_EXCL | APR_BINARY),
225 APR_OS_DEFAULT, pool);
226 if (apr_err)
227 return svn_error_create(apr_err, NULL, fname);
229 for (i = 0; i < (sizeof(lines) / sizeof(*lines)); i++)
231 const char *this_eol_str = eol_str ? eol_str : random_eol_marker();
233 apr_err = apr_file_printf(f, lines[i]);
235 /* Is it overly paranoid to use putc(), because of worry about
236 fprintf() doing a newline conversion? */
237 for (j = 0; this_eol_str[j]; j++)
239 apr_err = apr_file_putc(this_eol_str[j], f);
240 if (apr_err)
241 return svn_error_create(apr_err, NULL, fname);
245 apr_err = apr_file_close(f);
246 if (apr_err)
247 return svn_error_create(apr_err, NULL, fname);
249 return SVN_NO_ERROR;
253 /* If FNAME is a regular file, remove it; if it doesn't exist at all,
254 return success. Otherwise, return error. */
255 static svn_error_t *
256 remove_file(const char *fname, apr_pool_t *pool)
258 apr_status_t apr_err;
259 apr_finfo_t finfo;
261 if (apr_stat(&finfo, fname, APR_FINFO_TYPE, pool) == APR_SUCCESS)
263 if (finfo.filetype == APR_REG)
265 apr_err = apr_file_remove(fname, pool);
266 if (apr_err)
267 return svn_error_create(apr_err, NULL, fname);
269 else
270 return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
271 "non-file '%s' is in the way", fname);
274 return SVN_NO_ERROR;
278 /* Set up, run, and verify the results of a substitution.
280 * Create a file TEST_NAME.src using global `lines' as the initial
281 * data, with SRC_EOL as the line separator, then convert it to file
282 * TEST_NAME.dst (using DST_EOL, REPAIR, EXPAND, REV, AUTHOR, DATE,
283 * and URL as svn_subst_copy_and_translate() does), and verify that the
284 * conversion worked. Null SRC_EOL means create a mixed eol src
285 * file.
287 * If the verification succeeds, remove both files and return
288 * SVN_NO_ERROR.
290 * If the verification fails, leave the files for post-mortem. If the
291 * failure is due to non-eol data being wrong, return
292 * SVN_ERR_MALFORMED_FILE. If the problem is an incorrect eol marker,
293 * return SVN_ERR_IO_UNKNOWN_EOL. If the problem is that a mixed eol
294 * style was repaired even though no repair flag was passed, return
295 * SVN_ERR_TEST_FAILED.
297 * Use POOL for temporary allocation.
299 * Note: as with svn_subst_copy_and_translate(), if any of DST_EOL, REV,
300 * AUTHOR, DATE, and/or URL is null, then that substitution is not
301 * performed.
303 static svn_error_t *
304 substitute_and_verify(const char *test_name,
305 const char *src_eol,
306 const char *dst_eol,
307 svn_boolean_t repair,
308 const char *rev,
309 const char *date,
310 const char *author,
311 const char *url,
312 svn_boolean_t expand,
313 apr_pool_t *pool)
315 svn_error_t *err;
316 svn_stringbuf_t *contents;
317 apr_hash_t *keywords = apr_hash_make(pool);
318 apr_size_t idx = 0;
319 apr_size_t i;
320 const char *expect[(sizeof(lines) / sizeof(*lines))];
321 const char *src_fname = apr_pstrcat(pool, test_name, ".src", NULL);
322 const char *dst_fname = apr_pstrcat(pool, test_name, ".dst", NULL);
323 svn_string_t *val;
324 apr_pool_t *subpool = svn_pool_create(pool);
326 /** Clean up from previous tests, set up src data, and convert. **/
327 SVN_ERR(remove_file(src_fname, pool));
328 SVN_ERR(remove_file(dst_fname, pool));
329 SVN_ERR(create_file(src_fname, src_eol, pool));
331 if (rev)
333 val = svn_string_create(rev, pool);
334 apr_hash_set(keywords, SVN_KEYWORD_REVISION_LONG,
335 APR_HASH_KEY_STRING, val);
336 apr_hash_set(keywords, SVN_KEYWORD_REVISION_MEDIUM,
337 APR_HASH_KEY_STRING, val);
338 apr_hash_set(keywords, SVN_KEYWORD_REVISION_SHORT,
339 APR_HASH_KEY_STRING, val);
341 if (date)
343 val = svn_string_create(date, pool);
344 apr_hash_set(keywords, SVN_KEYWORD_DATE_LONG,
345 APR_HASH_KEY_STRING, val);
346 apr_hash_set(keywords, SVN_KEYWORD_DATE_SHORT,
347 APR_HASH_KEY_STRING, val);
349 if (author)
351 val = svn_string_create(author, pool);
352 apr_hash_set(keywords, SVN_KEYWORD_AUTHOR_LONG,
353 APR_HASH_KEY_STRING, val);
354 apr_hash_set(keywords, SVN_KEYWORD_AUTHOR_SHORT,
355 APR_HASH_KEY_STRING, val);
357 if (url)
359 val = svn_string_create(url, pool);
360 apr_hash_set(keywords, SVN_KEYWORD_URL_LONG,
361 APR_HASH_KEY_STRING, val);
362 apr_hash_set(keywords, SVN_KEYWORD_URL_SHORT,
363 APR_HASH_KEY_STRING, val);
366 err = svn_subst_copy_and_translate3(src_fname, dst_fname, dst_eol, repair,
367 keywords, expand, FALSE, subpool);
368 svn_pool_destroy(subpool);
370 /* Conversion should have failed, if src has mixed eol, and the
371 repair flag was not set, and we requested eol translation. */
372 if ((! src_eol) && dst_eol && (! repair))
374 if (! err)
376 return svn_error_createf
377 (SVN_ERR_TEST_FAILED, NULL,
378 "translation of '%s' should have failed, but didn't", src_fname);
380 else if (err->apr_err != SVN_ERR_IO_INCONSISTENT_EOL)
382 return svn_error_createf
383 (SVN_ERR_TEST_FAILED, err,
384 "translation of '%s' should fail, but not with this error",
385 src_fname);
387 else
389 svn_error_clear(err);
390 SVN_ERR(remove_file(src_fname, pool));
391 return SVN_NO_ERROR;
395 else if (err)
396 return err;
399 /** Verify that the conversion worked. **/
401 for (i = 0; i < (sizeof(expect) / sizeof(*expect)); i++)
402 expect[i] = lines[i];
404 /* Certain lines contain keywords; expect their expansions. */
405 if (rev)
407 if (expand)
409 expect[3 - 1] =
410 apr_pstrcat(pool, "Line 3: ",
411 "Valid $LastChangedRevision: ",
412 rev,
413 " $, started unexpanded.",
414 NULL);
415 expect[5 - 1] =
416 apr_pstrcat(pool, "Line 5: ",
417 "Valid $Rev: ", rev, " $, started unexpanded.",
418 NULL);
419 expect[26 - 1] =
420 apr_pstrcat(pool, "Line 26: ",
421 "Emptily expanded keyword $Rev: ", rev," $.",
422 NULL);
423 expect[29 - 1] =
424 apr_pstrcat(pool, "Line 29: ",
425 "Valid $LastChangedRevision: ",
426 rev,
427 " $, started expanded.",
428 NULL);
429 expect[30 - 1] =
430 apr_pstrcat(pool, "Line 30: ",
431 "Valid $Rev: ",
432 rev,
433 " $, started expanded.",
434 NULL);
436 else /* unexpand */
438 /* Lines 3 and 5 remain unchanged. */
439 expect[26 - 1] =
440 "Line 26: Emptily expanded keyword $Rev$.";
441 expect[29 - 1] =
442 "Line 29: Valid $LastChangedRevision$, started expanded.";
443 expect[30 - 1] =
444 "Line 30: Valid $Rev$, started expanded.";
448 if (date)
450 if (expand)
452 expect[12 - 1] =
453 apr_pstrcat(pool, "Line 12: ",
454 "Valid $LastChangedDate: ",
455 date,
456 " $, started unexpanded.",
457 NULL);
458 expect[13 - 1] =
459 apr_pstrcat(pool, "Line 13: ",
460 "Valid $Date: ", date, " $, started unexpanded.",
461 NULL);
462 expect[33 - 1] =
463 apr_pstrcat(pool, "Line 33: ",
464 "Valid $LastChangedDate: ",
465 date,
466 " $, started expanded.",
467 NULL);
468 expect[34 - 1] =
469 apr_pstrcat(pool, "Line 34: ",
470 "Valid $Date: ", date, " $, started expanded.",
471 NULL);
472 expect[51 - 1] =
473 apr_pstrcat(pool, "Line 51: ",
474 "same, but with embedded keyword ",
475 "$$$$$$$$Date: ", date, " $$$$$$$$$$.",
476 NULL);
477 expect[52 - 1] =
478 apr_pstrcat(pool, "Line 52: ",
479 "same, with expanded, empty keyword ",
480 "$$$$$$Date: ", date, " $$$$$$.",
481 NULL);
483 else /* unexpand */
485 /* Lines 12 and 13 remain unchanged. */
486 expect[33 - 1] =
487 "Line 33: Valid $LastChangedDate$, started expanded.";
488 expect[34 - 1] =
489 "Line 34: Valid $Date$, started expanded.";
490 expect[51 - 1] =
491 "Line 51: same, but with embedded keyword $$$$$$$$Date$$$$$$$$$$.";
492 expect[52 - 1] =
493 "Line 52: same, with expanded, empty keyword $$$$$$Date$$$$$$.";
497 if (author)
499 if (expand)
501 expect[8 - 1] =
502 apr_pstrcat(pool, "Line 8: ",
503 "Valid $LastChangedBy: ",
504 author,
505 " $, started unexpanded.",
506 NULL);
507 expect[9 - 1] =
508 apr_pstrcat(pool, "Line 9: ",
509 "Valid $Author: ", author, " $, started unexpanded.",
510 NULL);
511 expect[37 - 1] =
512 apr_pstrcat(pool, "Line 37: ",
513 "Valid $LastChangedBy: ", author,
514 " $, started expanded.", NULL);
515 expect[38 - 1] =
516 apr_pstrcat(pool, "Line 38: ",
517 "Valid $Author: ", author, " $, started expanded.",
518 NULL);
519 expect[46 - 1] =
520 apr_pstrcat(pool, "Line 46: ",
521 "Empty $Author: ", author, " $, started expanded.",
522 NULL);
523 expect[71 - 1] =
524 apr_pstrcat(pool, ".$veR$Author: ", author, " $", NULL);
526 expect[74 - 1] =
527 apr_pstrcat(pool, "Line 74: ",
528 "Valid $Author: ", author, " $, started expanded.",
529 NULL);
530 expect[79 - 1] =
531 apr_pstrcat(pool, "Line 79: ",
532 "Valid $Author: ", author, " $, started expanded.",
533 NULL);
534 expect[80 - 1] =
535 apr_pstrcat(pool, "Line 80: ",
536 "Valid $Author: ", author, " $, started expanded.",
537 NULL);
538 expect[81 - 1] =
539 apr_pstrcat(pool, "Line 81: ",
540 "Valid $Author: ", author, " $, started expanded.",
541 NULL);
542 expect[82 - 1] =
543 apr_pstrcat(pool, "Line 82: ",
544 "Valid $Author: ", author, " $, started expanded.",
545 NULL);
547 else /* unexpand */
549 /* Lines 8, 9, and 71 remain unchanged. */
550 expect[37 - 1] =
551 "Line 37: Valid $LastChangedBy$, started expanded.";
552 expect[38 - 1] =
553 "Line 38: Valid $Author$, started expanded.";
554 expect[46 - 1] =
555 "Line 46: Empty $Author$, started expanded.";
556 expect[74 - 1] =
557 "Line 74: Valid $Author$, started expanded.";
558 expect[79 - 1] =
559 "Line 79: Valid $Author$, started expanded.";
560 expect[80 - 1] =
561 "Line 80: Valid $Author$, started expanded.";
562 expect[81 - 1] =
563 "Line 81: Valid $Author$, started expanded.";
564 expect[82 - 1] =
565 "Line 82: Valid $Author$, started expanded.";
569 if (url)
571 if (expand)
573 expect[16 - 1] =
574 apr_pstrcat(pool, "Line 16: ",
575 "Valid $HeadURL: ", url, " $, started unexpanded.",
576 NULL);
577 expect[17 - 1] =
578 apr_pstrcat(pool, "Line 17: ",
579 "Valid $URL: ", url, " $, started unexpanded.",
580 NULL);
581 expect[41 - 1] =
582 apr_pstrcat(pool, "Line 41: ",
583 "Valid $HeadURL: ", url, " $, started expanded.",
584 NULL);
585 expect[42 - 1] =
586 apr_pstrcat(pool, "Line 42: ",
587 "Valid $URL: ", url, " $, started expanded.",
588 NULL);
589 expect[75 - 1] =
590 apr_pstrcat(pool, "Line 75: ",
591 "Valid $URL: ", url, " $, started expanded.",
592 NULL);
594 else /* unexpand */
596 /* Lines 16 and 17 and remain unchanged. */
597 expect[41 - 1] =
598 "Line 41: Valid $HeadURL$, started expanded.";
599 expect[42 - 1] =
600 "Line 42: Valid $URL$, started expanded.";
601 expect[75 - 1] =
602 "Line 75: Valid $URL$, started expanded.";
606 /* Handle lines 48, 49, and 70 specially, as they contains two valid
607 keywords. */
608 if (rev && author)
610 if (expand)
612 expect[48 - 1] =
613 apr_pstrcat(pool, "Line 48: ",
614 "Two keywords back to back: "
615 "$Author: ", author, " $"
616 "$Rev: ", rev, " $.",
617 NULL);
618 expect[49 - 1] =
619 apr_pstrcat(pool, "Line 49: ",
620 "One keyword, one not, back to back: "
621 "$Author: ", author, " $Rev$.",
622 NULL);
623 expect[70 - 1] =
624 apr_pstrcat(pool, "$Author: ", author, " $Rev$.", NULL);
626 /* Else Lines 48, 49, and 70 remain unchanged. */
628 else if (rev && (! author))
630 if (expand)
632 expect[48 - 1] =
633 apr_pstrcat(pool, "Line 48: ",
634 "Two keywords back to back: "
635 "$Author$$Rev: ", rev, " $.",
636 NULL);
637 expect[49 - 1] =
638 apr_pstrcat(pool, "Line 49: ",
639 "One keyword, one not, back to back: "
640 "$Author$Rev: ", rev, " $.",
641 NULL);
642 expect[70 - 1] =
643 apr_pstrcat(pool, "$Author$Rev: ", rev, " $.", NULL);
645 /* Else Lines 48, 49, and 70 remain unchanged. */
647 else if ((! rev) && author)
649 if (expand)
651 expect[48 - 1] =
652 apr_pstrcat(pool, "Line 48: ",
653 "Two keywords back to back: "
654 "$Author: ", author, " $$Rev$.",
655 NULL);
656 expect[49 - 1] =
657 apr_pstrcat(pool, "Line 49: ",
658 "One keyword, one not, back to back: "
659 "$Author: ", author, " $Rev$.",
660 NULL);
661 expect[70 - 1] =
662 apr_pstrcat(pool, "$Author: ", author, " $Rev$.", NULL);
664 /* Else Lines 48, 49, and 70 remain unchanged. */
666 /* Else neither rev nor author, so Lines 48, 49, and 70 remain
667 unchanged. */
669 /* Handle line 24 specially, as it contains two valid keywords. */
670 if (date && author)
672 if (expand)
674 expect[24 - 1] =
675 apr_pstrcat(pool, "Line 24: ",
676 "keyword in a keyword: $Author: ",
677 author,
678 " $Date$ $",
679 NULL);
681 else /* unexpand */
683 expect[24 - 1] =
684 apr_pstrcat(pool, "Line 24: ",
685 "keyword in a keyword: $Author$Date$ $",
686 NULL);
689 else if (date && (! author))
691 if (expand)
693 expect[24 - 1] =
694 apr_pstrcat(pool, "Line 24: ",
695 "keyword in a keyword: $Author: $Date: ",
696 date,
697 " $ $",
698 NULL);
700 /* Else Line 24 remains unchanged. */
702 else if ((! date) && author)
704 if (expand)
706 expect[24 - 1] =
707 apr_pstrcat(pool, "Line 24: ",
708 "keyword in a keyword: $Author: ",
709 author,
710 " $Date$ $",
711 NULL);
713 else /* unexpand */
715 expect[24 - 1] =
716 apr_pstrcat(pool, "Line 24: ",
717 "keyword in a keyword: $Author$Date$ $",
718 NULL);
721 /* Else neither author nor date, so Line 24 remains unchanged. */
723 /** Ready to verify. **/
725 SVN_ERR(svn_stringbuf_from_file(&contents, dst_fname, pool));
727 for (i = 0; i < (sizeof(expect) / sizeof(*expect)); i++)
729 if (contents->len < idx)
730 return svn_error_createf
731 (SVN_ERR_MALFORMED_FILE, NULL,
732 "'%s' has short contents at line %" APR_SIZE_T_FMT,
733 dst_fname, i + 1);
735 if (strncmp(contents->data + idx, expect[i], strlen(expect[i])) != 0)
736 return svn_error_createf
737 (SVN_ERR_MALFORMED_FILE, NULL,
738 "'%s' has wrong contents at line %" APR_SIZE_T_FMT,
739 dst_fname, i + 1);
741 /* Else, the data is correct, at least up to the next eol. */
743 idx += strlen(expect[i]);
745 if (dst_eol) /* verify the promised consistent eol style */
747 if (strncmp(contents->data + idx, dst_eol, strlen(dst_eol)) != 0)
748 return svn_error_createf
749 (SVN_ERR_IO_UNKNOWN_EOL, NULL,
750 "'%s' has wrong eol style at line %" APR_SIZE_T_FMT, dst_fname,
751 i + 1);
752 else
753 idx += strlen(dst_eol);
755 else /* allow any eol style, even inconsistent ones, loosely */
757 while ((*(contents->data + idx) == '\r')
758 || (*(contents->data + idx) == '\n'))
759 idx++;
763 /* Clean up this test, since successful. */
764 SVN_ERR(remove_file(src_fname, pool));
765 SVN_ERR(remove_file(dst_fname, pool));
767 return SVN_NO_ERROR;
772 static svn_error_t *
773 noop(const char **msg,
774 svn_boolean_t msg_only,
775 svn_test_opts_t *opts,
776 apr_pool_t *pool)
778 *msg = "no conversions";
780 if (msg_only)
781 return SVN_NO_ERROR;
783 SVN_ERR(substitute_and_verify
784 ("noop", NULL, NULL, 0, NULL, NULL, NULL, NULL, 1, pool));
786 SVN_ERR(substitute_and_verify
787 ("noop", "\r", NULL, 0, NULL, NULL, NULL, NULL, 1, pool));
789 SVN_ERR(substitute_and_verify
790 ("noop", "\n", NULL, 0, NULL, NULL, NULL, NULL, 1, pool));
792 SVN_ERR(substitute_and_verify
793 ("noop", "\r\n", NULL, 0, NULL, NULL, NULL, NULL, 1, pool));
795 return SVN_NO_ERROR;
801 /** EOL conversion alone. **/
803 static svn_error_t *
804 crlf_to_crlf(const char **msg,
805 svn_boolean_t msg_only,
806 svn_test_opts_t *opts,
807 apr_pool_t *pool)
809 *msg = "convert CRLF to CRLF";
811 if (msg_only)
812 return SVN_NO_ERROR;
814 SVN_ERR(substitute_and_verify
815 ("crlf_to_crlf", "\r\n", "\r\n", 0,
816 NULL, NULL, NULL, NULL, 1, pool));
818 return SVN_NO_ERROR;
822 static svn_error_t *
823 lf_to_crlf(const char **msg,
824 svn_boolean_t msg_only,
825 svn_test_opts_t *opts,
826 apr_pool_t *pool)
828 *msg = "convert LF to CRLF";
830 if (msg_only)
831 return SVN_NO_ERROR;
833 SVN_ERR(substitute_and_verify
834 ("lf_to_crlf", "\n", "\r\n", 0, NULL, NULL, NULL, NULL, 1, pool));
836 return SVN_NO_ERROR;
840 static svn_error_t *
841 cr_to_crlf(const char **msg,
842 svn_boolean_t msg_only,
843 svn_test_opts_t *opts,
844 apr_pool_t *pool)
846 *msg = "convert CR to CRLF";
848 if (msg_only)
849 return SVN_NO_ERROR;
851 SVN_ERR(substitute_and_verify
852 ("cr_to_crlf", "\r", "\r\n", 0, NULL, NULL, NULL, NULL, 1, pool));
854 return SVN_NO_ERROR;
858 static svn_error_t *
859 mixed_to_crlf(const char **msg,
860 svn_boolean_t msg_only,
861 svn_test_opts_t *opts,
862 apr_pool_t *pool)
864 *msg = "convert mixed line endings to CRLF";
866 if (msg_only)
867 return SVN_NO_ERROR;
869 SVN_ERR(substitute_and_verify
870 ("mixed_to_crlf", NULL, "\r\n", 1,
871 NULL, NULL, NULL, NULL, 1, pool));
873 return SVN_NO_ERROR;
877 static svn_error_t *
878 lf_to_lf(const char **msg,
879 svn_boolean_t msg_only,
880 svn_test_opts_t *opts,
881 apr_pool_t *pool)
883 *msg = "convert LF to LF";
885 if (msg_only)
886 return SVN_NO_ERROR;
888 SVN_ERR(substitute_and_verify
889 ("lf_to_lf", "\n", "\n", 0, NULL, NULL, NULL, NULL, 1, pool));
891 return SVN_NO_ERROR;
895 static svn_error_t *
896 crlf_to_lf(const char **msg,
897 svn_boolean_t msg_only,
898 svn_test_opts_t *opts,
899 apr_pool_t *pool)
901 *msg = "convert CRLF to LF";
903 if (msg_only)
904 return SVN_NO_ERROR;
906 SVN_ERR(substitute_and_verify
907 ("crlf_to_lf", "\r\n", "\n", 0, NULL, NULL, NULL, NULL, 1, pool));
909 return SVN_NO_ERROR;
913 static svn_error_t *
914 cr_to_lf(const char **msg,
915 svn_boolean_t msg_only,
916 svn_test_opts_t *opts,
917 apr_pool_t *pool)
919 *msg = "convert CR to LF";
921 if (msg_only)
922 return SVN_NO_ERROR;
924 SVN_ERR(substitute_and_verify
925 ("cr_to_lf", "\r", "\n", 0, NULL, NULL, NULL, NULL, 1, pool));
927 return SVN_NO_ERROR;
931 static svn_error_t *
932 mixed_to_lf(const char **msg,
933 svn_boolean_t msg_only,
934 svn_test_opts_t *opts,
935 apr_pool_t *pool)
937 *msg = "convert mixed line endings to LF";
939 if (msg_only)
940 return SVN_NO_ERROR;
942 SVN_ERR(substitute_and_verify
943 ("cr_to_lf", NULL, "\n", 1, NULL, NULL, NULL, NULL, 1, pool));
945 return SVN_NO_ERROR;
949 static svn_error_t *
950 crlf_to_cr(const char **msg,
951 svn_boolean_t msg_only,
952 svn_test_opts_t *opts,
953 apr_pool_t *pool)
955 *msg = "convert CRLF to CR";
957 if (msg_only)
958 return SVN_NO_ERROR;
960 SVN_ERR(substitute_and_verify
961 ("crlf_to_cr", "\r\n", "\r", 0, NULL, NULL, NULL, NULL, 1, pool));
963 return SVN_NO_ERROR;
967 static svn_error_t *
968 lf_to_cr(const char **msg,
969 svn_boolean_t msg_only,
970 svn_test_opts_t *opts,
971 apr_pool_t *pool)
973 *msg = "convert LF to CR";
975 if (msg_only)
976 return SVN_NO_ERROR;
978 SVN_ERR(substitute_and_verify
979 ("lf_to_cr", "\n", "\r", 0, NULL, NULL, NULL, NULL, 1, pool));
981 return SVN_NO_ERROR;
985 static svn_error_t *
986 cr_to_cr(const char **msg,
987 svn_boolean_t msg_only,
988 svn_test_opts_t *opts,
989 apr_pool_t *pool)
991 *msg = "convert CR to CR";
993 if (msg_only)
994 return SVN_NO_ERROR;
996 SVN_ERR(substitute_and_verify
997 ("cr_to_cr", "\r", "\r", 0, NULL, NULL, NULL, NULL, 1, pool));
999 return SVN_NO_ERROR;
1003 static svn_error_t *
1004 mixed_to_cr(const char **msg,
1005 svn_boolean_t msg_only,
1006 svn_test_opts_t *opts,
1007 apr_pool_t *pool)
1009 *msg = "convert mixed line endings to CR";
1011 if (msg_only)
1012 return SVN_NO_ERROR;
1014 SVN_ERR(substitute_and_verify
1015 ("mixed_to_cr", NULL, "\r", 1, NULL, NULL, NULL, NULL, 1, pool));
1017 return SVN_NO_ERROR;
1021 static svn_error_t *
1022 mixed_no_repair(const char **msg,
1023 svn_boolean_t msg_only,
1024 svn_test_opts_t *opts,
1025 apr_pool_t *pool)
1027 *msg = "keep mixed line endings without repair flag";
1029 if (msg_only)
1030 return SVN_NO_ERROR;
1032 SVN_ERR(substitute_and_verify
1033 ("mixed_no_repair", NULL, "\n", 0,
1034 NULL, NULL, NULL, NULL, 1, pool));
1036 SVN_ERR(substitute_and_verify
1037 ("mixed_no_repair", NULL, "\r\n", 0,
1038 NULL, NULL, NULL, NULL, 1, pool));
1040 return SVN_NO_ERROR;
1045 /** Keyword expansion alone. **/
1047 static svn_error_t *
1048 expand_author(const char **msg,
1049 svn_boolean_t msg_only,
1050 svn_test_opts_t *opts,
1051 apr_pool_t *pool)
1053 *msg = "expand author";
1055 if (msg_only)
1056 return SVN_NO_ERROR;
1058 SVN_ERR(substitute_and_verify
1059 ("author", "\n", NULL, 0, NULL, NULL, "jrandom", NULL, 1, pool));
1061 SVN_ERR(substitute_and_verify
1062 ("author", "\r\n", NULL, 0, NULL, NULL, "jrandom", NULL, 1, pool));
1064 return SVN_NO_ERROR;
1068 static svn_error_t *
1069 expand_date(const char **msg,
1070 svn_boolean_t msg_only,
1071 svn_test_opts_t *opts,
1072 apr_pool_t *pool)
1074 *msg = "expand date";
1076 if (msg_only)
1077 return SVN_NO_ERROR;
1079 SVN_ERR(substitute_and_verify
1080 ("date", "\n", NULL, 0,
1081 NULL, "Wed Jan 9 07:49:05 2002", NULL, NULL, 1, pool));
1083 SVN_ERR(substitute_and_verify
1084 ("date", "\r\n", NULL, 0,
1085 NULL, "Wed Jan 9 07:49:05 2002", NULL, NULL, 1, pool));
1087 return SVN_NO_ERROR;
1091 static svn_error_t *
1092 expand_author_date(const char **msg,
1093 svn_boolean_t msg_only,
1094 svn_test_opts_t *opts,
1095 apr_pool_t *pool)
1097 *msg = "expand author and date";
1099 if (msg_only)
1100 return SVN_NO_ERROR;
1102 SVN_ERR(substitute_and_verify
1103 ("author_date", "\n", NULL, 0,
1104 NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 1, pool));
1106 SVN_ERR(substitute_and_verify
1107 ("author_date", "\r\n", NULL, 0,
1108 NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 1, pool));
1110 return SVN_NO_ERROR;
1114 static svn_error_t *
1115 expand_author_rev(const char **msg,
1116 svn_boolean_t msg_only,
1117 svn_test_opts_t *opts,
1118 apr_pool_t *pool)
1120 *msg = "expand author and rev";
1122 if (msg_only)
1123 return SVN_NO_ERROR;
1125 SVN_ERR(substitute_and_verify
1126 ("author_rev", "\n", NULL, 0,
1127 "1729", NULL, "jrandom", NULL, 1, pool));
1129 SVN_ERR(substitute_and_verify
1130 ("author_rev", "\r\n", NULL, 0,
1131 "1729", NULL, "jrandom", NULL, 1, pool));
1133 return SVN_NO_ERROR;
1137 static svn_error_t *
1138 expand_rev(const char **msg,
1139 svn_boolean_t msg_only,
1140 svn_test_opts_t *opts,
1141 apr_pool_t *pool)
1143 *msg = "expand rev";
1145 if (msg_only)
1146 return SVN_NO_ERROR;
1148 SVN_ERR(substitute_and_verify
1149 ("rev", "\n", NULL, 0,
1150 "1729", NULL, NULL, NULL, 1, pool));
1152 SVN_ERR(substitute_and_verify
1153 ("rev", "\r\n", NULL, 0,
1154 "1729", NULL, NULL, NULL, 1, pool));
1156 return SVN_NO_ERROR;
1160 static svn_error_t *
1161 expand_rev_url(const char **msg,
1162 svn_boolean_t msg_only,
1163 svn_test_opts_t *opts,
1164 apr_pool_t *pool)
1166 *msg = "expand rev and url";
1168 if (msg_only)
1169 return SVN_NO_ERROR;
1171 SVN_ERR(substitute_and_verify
1172 ("rev_url", "\n", NULL, 0,
1173 "1729", NULL, NULL, "http://subversion.tigris.org", 1, pool));
1175 SVN_ERR(substitute_and_verify
1176 ("rev_url", "\r\n", NULL, 0,
1177 "1729", NULL, NULL, "http://subversion.tigris.org", 1, pool));
1179 return SVN_NO_ERROR;
1183 static svn_error_t *
1184 expand_author_date_rev_url(const char **msg,
1185 svn_boolean_t msg_only,
1186 svn_test_opts_t *opts,
1187 apr_pool_t *pool)
1189 *msg = "expand author, date, rev, and url";
1191 if (msg_only)
1192 return SVN_NO_ERROR;
1194 SVN_ERR(substitute_and_verify
1195 ("author_date_rev_url", "\n", NULL, 0,
1196 "1729",
1197 "Wed Jan 9 07:49:05 2002",
1198 "jrandom",
1199 "http://subversion.tigris.org",
1200 1, pool));
1202 SVN_ERR(substitute_and_verify
1203 ("author_date_rev_url", "\r\n", NULL, 0,
1204 "1729",
1205 "Wed Jan 9 07:49:05 2002",
1206 "jrandom",
1207 "http://subversion.tigris.org",
1208 1, pool));
1210 return SVN_NO_ERROR;
1215 /** Keyword expansion and EOL conversion together. **/
1217 static svn_error_t *
1218 lf_to_crlf_expand_author(const char **msg,
1219 svn_boolean_t msg_only,
1220 svn_test_opts_t *opts,
1221 apr_pool_t *pool)
1223 *msg = "lf_to_crlf; expand author";
1225 if (msg_only)
1226 return SVN_NO_ERROR;
1228 SVN_ERR(substitute_and_verify
1229 ("lf_to_crlf_author", "\n", "\r\n", 0,
1230 NULL, NULL, "jrandom", NULL, 1, pool));
1232 return SVN_NO_ERROR;
1236 static svn_error_t *
1237 mixed_to_lf_expand_author_date(const char **msg,
1238 svn_boolean_t msg_only,
1239 svn_test_opts_t *opts,
1240 apr_pool_t *pool)
1242 *msg = "mixed_to_lf; expand author and date";
1244 if (msg_only)
1245 return SVN_NO_ERROR;
1247 SVN_ERR(substitute_and_verify
1248 ("mixed_to_lf_author_date", NULL, "\n", 1,
1249 NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 1, pool));
1251 return SVN_NO_ERROR;
1255 static svn_error_t *
1256 crlf_to_cr_expand_author_rev(const char **msg,
1257 svn_boolean_t msg_only,
1258 svn_test_opts_t *opts,
1259 apr_pool_t *pool)
1261 *msg = "crlf_to_cr; expand author and rev";
1263 if (msg_only)
1264 return SVN_NO_ERROR;
1266 SVN_ERR(substitute_and_verify
1267 ("crlf_to_cr_author_rev", "\r\n", "\r", 0,
1268 "1729", NULL, "jrandom", NULL, 1, pool));
1270 return SVN_NO_ERROR;
1274 static svn_error_t *
1275 cr_to_crlf_expand_rev(const char **msg,
1276 svn_boolean_t msg_only,
1277 svn_test_opts_t *opts,
1278 apr_pool_t *pool)
1280 *msg = "cr_to_crlf; expand rev";
1282 if (msg_only)
1283 return SVN_NO_ERROR;
1285 SVN_ERR(substitute_and_verify
1286 ("cr_to_crlf_rev", "\r", "\r\n", 0,
1287 "1729", NULL, NULL, NULL, 1, pool));
1289 return SVN_NO_ERROR;
1293 static svn_error_t *
1294 cr_to_crlf_expand_rev_url(const char **msg,
1295 svn_boolean_t msg_only,
1296 svn_test_opts_t *opts,
1297 apr_pool_t *pool)
1299 *msg = "cr_to_crlf; expand rev and url";
1301 if (msg_only)
1302 return SVN_NO_ERROR;
1304 SVN_ERR(substitute_and_verify
1305 ("cr_to_crlf_rev_url", "\r", "\r\n", 0,
1306 "1729", NULL, NULL, "http://subversion.tigris.org", 1, pool));
1308 return SVN_NO_ERROR;
1312 static svn_error_t *
1313 mixed_to_crlf_expand_author_date_rev_url(const char **msg,
1314 svn_boolean_t msg_only,
1315 svn_test_opts_t *opts,
1316 apr_pool_t *pool)
1318 *msg = "mixed_to_crlf; expand author, date, rev, and url";
1320 if (msg_only)
1321 return SVN_NO_ERROR;
1323 SVN_ERR(substitute_and_verify
1324 ("mixed_to_crlf_author_date_rev_url", NULL, "\r\n", 1,
1325 "1729",
1326 "Wed Jan 9 07:49:05 2002",
1327 "jrandom",
1328 "http://subversion.tigris.org",
1330 pool));
1332 return SVN_NO_ERROR;
1337 /** Keyword unexpansion alone. **/
1339 static svn_error_t *
1340 unexpand_author(const char **msg,
1341 svn_boolean_t msg_only,
1342 svn_test_opts_t *opts,
1343 apr_pool_t *pool)
1345 *msg = "unexpand author";
1347 if (msg_only)
1348 return SVN_NO_ERROR;
1350 SVN_ERR(substitute_and_verify
1351 ("author", "\n", NULL, 0, NULL, NULL, "jrandom", NULL, 0, pool));
1353 SVN_ERR(substitute_and_verify
1354 ("author", "\r\n", NULL, 0, NULL, NULL, "jrandom", NULL, 0, pool));
1356 return SVN_NO_ERROR;
1360 static svn_error_t *
1361 unexpand_date(const char **msg,
1362 svn_boolean_t msg_only,
1363 svn_test_opts_t *opts,
1364 apr_pool_t *pool)
1366 *msg = "unexpand date";
1368 if (msg_only)
1369 return SVN_NO_ERROR;
1371 SVN_ERR(substitute_and_verify
1372 ("date", "\n", NULL, 0,
1373 NULL, "Wed Jan 9 07:49:05 2002", NULL, NULL, 0, pool));
1375 SVN_ERR(substitute_and_verify
1376 ("date", "\r\n", NULL, 0,
1377 NULL, "Wed Jan 9 07:49:05 2002", NULL, NULL, 0, pool));
1379 return SVN_NO_ERROR;
1383 static svn_error_t *
1384 unexpand_author_date(const char **msg,
1385 svn_boolean_t msg_only,
1386 svn_test_opts_t *opts,
1387 apr_pool_t *pool)
1389 *msg = "unexpand author and date";
1391 if (msg_only)
1392 return SVN_NO_ERROR;
1394 SVN_ERR(substitute_and_verify
1395 ("author_date", "\n", NULL, 0,
1396 NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 0, pool));
1398 SVN_ERR(substitute_and_verify
1399 ("author_date", "\r\n", NULL, 0,
1400 NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 0, pool));
1402 return SVN_NO_ERROR;
1406 static svn_error_t *
1407 unexpand_author_rev(const char **msg,
1408 svn_boolean_t msg_only,
1409 svn_test_opts_t *opts,
1410 apr_pool_t *pool)
1412 *msg = "unexpand author and rev";
1414 if (msg_only)
1415 return SVN_NO_ERROR;
1417 SVN_ERR(substitute_and_verify
1418 ("author_rev", "\n", NULL, 0,
1419 "1729", NULL, "jrandom", NULL, 0, pool));
1421 SVN_ERR(substitute_and_verify
1422 ("author_rev", "\r\n", NULL, 0,
1423 "1729", NULL, "jrandom", NULL, 0, pool));
1425 return SVN_NO_ERROR;
1429 static svn_error_t *
1430 unexpand_rev(const char **msg,
1431 svn_boolean_t msg_only,
1432 svn_test_opts_t *opts,
1433 apr_pool_t *pool)
1435 *msg = "unexpand rev";
1437 if (msg_only)
1438 return SVN_NO_ERROR;
1440 SVN_ERR(substitute_and_verify
1441 ("rev", "\n", NULL, 0,
1442 "1729", NULL, NULL, NULL, 0, pool));
1444 SVN_ERR(substitute_and_verify
1445 ("rev", "\r\n", NULL, 0,
1446 "1729", NULL, NULL, NULL, 0, pool));
1448 return SVN_NO_ERROR;
1452 static svn_error_t *
1453 unexpand_rev_url(const char **msg,
1454 svn_boolean_t msg_only,
1455 svn_test_opts_t *opts,
1456 apr_pool_t *pool)
1458 *msg = "unexpand rev and url";
1460 if (msg_only)
1461 return SVN_NO_ERROR;
1463 SVN_ERR(substitute_and_verify
1464 ("rev_url", "\n", NULL, 0,
1465 "1729", NULL, NULL, "http://subversion.tigris.org", 0, pool));
1467 SVN_ERR(substitute_and_verify
1468 ("rev_url", "\r\n", NULL, 0,
1469 "1729", NULL, NULL, "http://subversion.tigris.org", 0, pool));
1471 return SVN_NO_ERROR;
1475 static svn_error_t *
1476 unexpand_author_date_rev_url(const char **msg,
1477 svn_boolean_t msg_only,
1478 svn_test_opts_t *opts,
1479 apr_pool_t *pool)
1481 *msg = "unexpand author, date, rev, and url";
1483 if (msg_only)
1484 return SVN_NO_ERROR;
1486 SVN_ERR(substitute_and_verify
1487 ("author_date_rev_url", "\n", NULL, 0,
1488 "1729",
1489 "Wed Jan 9 07:49:05 2002",
1490 "jrandom",
1491 "http://subversion.tigris.org",
1492 1, pool));
1494 SVN_ERR(substitute_and_verify
1495 ("author_date_rev_url", "\r\n", NULL, 0,
1496 "1729",
1497 "Wed Jan 9 07:49:05 2002",
1498 "jrandom",
1499 "http://subversion.tigris.org",
1500 1, pool));
1502 return SVN_NO_ERROR;
1507 /** Keyword unexpansion and EOL conversion together. **/
1509 static svn_error_t *
1510 lf_to_crlf_unexpand_author(const char **msg,
1511 svn_boolean_t msg_only,
1512 svn_test_opts_t *opts,
1513 apr_pool_t *pool)
1515 *msg = "lf_to_crlf; unexpand author";
1517 if (msg_only)
1518 return SVN_NO_ERROR;
1520 SVN_ERR(substitute_and_verify
1521 ("lf_to_crlf_author", "\n", "\r\n", 0,
1522 NULL, NULL, "jrandom", NULL, 0, pool));
1524 return SVN_NO_ERROR;
1528 static svn_error_t *
1529 mixed_to_lf_unexpand_author_date(const char **msg,
1530 svn_boolean_t msg_only,
1531 svn_test_opts_t *opts,
1532 apr_pool_t *pool)
1534 *msg = "mixed_to_lf; unexpand author and date";
1536 if (msg_only)
1537 return SVN_NO_ERROR;
1539 SVN_ERR(substitute_and_verify
1540 ("mixed_to_lf_author_date", NULL, "\n", 1,
1541 NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 0, pool));
1543 return SVN_NO_ERROR;
1547 static svn_error_t *
1548 crlf_to_cr_unexpand_author_rev(const char **msg,
1549 svn_boolean_t msg_only,
1550 svn_test_opts_t *opts,
1551 apr_pool_t *pool)
1553 *msg = "crlf_to_cr; unexpand author and rev";
1555 if (msg_only)
1556 return SVN_NO_ERROR;
1558 SVN_ERR(substitute_and_verify
1559 ("crlf_to_cr_author_rev", "\r\n", "\r", 0,
1560 "1729", NULL, "jrandom", NULL, 0, pool));
1562 return SVN_NO_ERROR;
1566 static svn_error_t *
1567 cr_to_crlf_unexpand_rev(const char **msg,
1568 svn_boolean_t msg_only,
1569 svn_test_opts_t *opts,
1570 apr_pool_t *pool)
1572 *msg = "cr_to_crlf; unexpand rev";
1574 if (msg_only)
1575 return SVN_NO_ERROR;
1577 SVN_ERR(substitute_and_verify
1578 ("cr_to_crlf_rev", "\r", "\r\n", 0,
1579 "1729", NULL, NULL, NULL, 0, pool));
1581 return SVN_NO_ERROR;
1585 static svn_error_t *
1586 cr_to_crlf_unexpand_rev_url(const char **msg,
1587 svn_boolean_t msg_only,
1588 svn_test_opts_t *opts,
1589 apr_pool_t *pool)
1591 *msg = "cr_to_crlf; unexpand rev and url";
1593 if (msg_only)
1594 return SVN_NO_ERROR;
1596 SVN_ERR(substitute_and_verify
1597 ("cr_to_crlf_rev_url", "\r", "\r\n", 0,
1598 "1729", NULL, NULL, "http://subversion.tigris.org", 0, pool));
1600 return SVN_NO_ERROR;
1604 static svn_error_t *
1605 mixed_to_crlf_unexpand_author_date_rev_url(const char **msg,
1606 svn_boolean_t msg_only,
1607 svn_test_opts_t *opts,
1608 apr_pool_t *pool)
1610 *msg = "mixed_to_crlf; unexpand author, date, rev, url";
1612 if (msg_only)
1613 return SVN_NO_ERROR;
1615 SVN_ERR(substitute_and_verify
1616 ("mixed_to_crlf_author_date_rev_url", NULL, "\r\n", 1,
1617 "1729",
1618 "Wed Jan 9 07:49:05 2002",
1619 "jrandom",
1620 "http://subversion.tigris.org",
1622 pool));
1624 return SVN_NO_ERROR;
1629 /* The test table. */
1631 struct svn_test_descriptor_t test_funcs[] =
1633 SVN_TEST_NULL,
1634 /* The no-op conversion. */
1635 SVN_TEST_PASS(noop),
1636 /* Conversions resulting in crlf, no keywords involved. */
1637 SVN_TEST_PASS(crlf_to_crlf),
1638 SVN_TEST_PASS(lf_to_crlf),
1639 SVN_TEST_PASS(cr_to_crlf),
1640 SVN_TEST_PASS(mixed_to_crlf),
1641 /* Conversions resulting in lf, no keywords involved. */
1642 SVN_TEST_PASS(lf_to_lf),
1643 SVN_TEST_PASS(crlf_to_lf),
1644 SVN_TEST_PASS(cr_to_lf),
1645 SVN_TEST_PASS(mixed_to_lf),
1646 /* Conversions resulting in cr, no keywords involved. */
1647 SVN_TEST_PASS(crlf_to_cr),
1648 SVN_TEST_PASS(lf_to_cr),
1649 SVN_TEST_PASS(cr_to_cr),
1650 SVN_TEST_PASS(mixed_to_cr),
1651 /* Random eol stuff. */
1652 SVN_TEST_PASS(mixed_no_repair),
1653 /* Keyword expansion alone, no eol conversion involved. */
1654 SVN_TEST_PASS(expand_author),
1655 SVN_TEST_PASS(expand_date),
1656 SVN_TEST_PASS(expand_author_date),
1657 SVN_TEST_PASS(expand_author_rev),
1658 SVN_TEST_PASS(expand_rev),
1659 SVN_TEST_PASS(expand_rev_url),
1660 SVN_TEST_PASS(expand_author_date_rev_url),
1661 /* Keyword expansion and eol conversion together. */
1662 SVN_TEST_PASS(lf_to_crlf_expand_author),
1663 SVN_TEST_PASS(mixed_to_lf_expand_author_date),
1664 SVN_TEST_PASS(crlf_to_cr_expand_author_rev),
1665 SVN_TEST_PASS(cr_to_crlf_expand_rev),
1666 SVN_TEST_PASS(cr_to_crlf_expand_rev_url),
1667 SVN_TEST_PASS(mixed_to_crlf_expand_author_date_rev_url),
1668 /* Keyword unexpansion alone, no eol conversion involved. */
1669 SVN_TEST_PASS(unexpand_author),
1670 SVN_TEST_PASS(unexpand_date),
1671 SVN_TEST_PASS(unexpand_author_date),
1672 SVN_TEST_PASS(unexpand_author_rev),
1673 SVN_TEST_PASS(unexpand_rev),
1674 SVN_TEST_PASS(unexpand_rev_url),
1675 SVN_TEST_PASS(unexpand_author_date_rev_url),
1676 /* Keyword unexpansion and eol conversion together. */
1677 SVN_TEST_PASS(lf_to_crlf_unexpand_author),
1678 SVN_TEST_PASS(mixed_to_lf_unexpand_author_date),
1679 SVN_TEST_PASS(crlf_to_cr_unexpand_author_rev),
1680 SVN_TEST_PASS(cr_to_crlf_unexpand_rev),
1681 SVN_TEST_PASS(cr_to_crlf_unexpand_rev_url),
1682 SVN_TEST_PASS(mixed_to_crlf_unexpand_author_date_rev_url),
1683 SVN_TEST_NULL