📄 translate-test.c
字号:
expect[29 - 1] = apr_pstrcat(pool, "Line 29: ", "Valid $LastChangedRevision: ", rev, " $, started expanded.", NULL); expect[30 - 1] = apr_pstrcat(pool, "Line 30: ", "Valid $Rev: ", rev, " $, started expanded.", NULL); } else /* unexpand */ { /* Lines 3 and 5 remain unchanged. */ expect[26 - 1] = "Line 26: Emptily expanded keyword $Rev$."; expect[29 - 1] = "Line 29: Valid $LastChangedRevision$, started expanded."; expect[30 - 1] = "Line 30: Valid $Rev$, started expanded."; } } if (date) { if (expand) { expect[12 - 1] = apr_pstrcat(pool, "Line 12: ", "Valid $LastChangedDate: ", date, " $, started unexpanded.", NULL); expect[13 - 1] = apr_pstrcat(pool, "Line 13: ", "Valid $Date: ", date, " $, started unexpanded.", NULL); expect[33 - 1] = apr_pstrcat(pool, "Line 33: ", "Valid $LastChangedDate: ", date, " $, started expanded.", NULL); expect[34 - 1] = apr_pstrcat(pool, "Line 34: ", "Valid $Date: ", date, " $, started expanded.", NULL); expect[51 - 1] = apr_pstrcat(pool, "Line 51: ", "same, but with embedded keyword ", "$$$$$$$$Date: ", date, " $$$$$$$$$$.", NULL); expect[52 - 1] = apr_pstrcat(pool, "Line 52: ", "same, with expanded, empty keyword ", "$$$$$$Date: ", date, " $$$$$$.", NULL); } else /* unexpand */ { /* Lines 12 and 13 remain unchanged. */ expect[33 - 1] = "Line 33: Valid $LastChangedDate$, started expanded."; expect[34 - 1] = "Line 34: Valid $Date$, started expanded."; expect[51 - 1] = "Line 51: same, but with embedded keyword $$$$$$$$Date$$$$$$$$$$."; expect[52 - 1] = "Line 52: same, with expanded, empty keyword $$$$$$Date$$$$$$."; } } if (author) { if (expand) { expect[8 - 1] = apr_pstrcat(pool, "Line 8: ", "Valid $LastChangedBy: ", author, " $, started unexpanded.", NULL); expect[9 - 1] = apr_pstrcat(pool, "Line 9: ", "Valid $Author: ", author, " $, started unexpanded.", NULL); expect[37 - 1] = apr_pstrcat(pool, "Line 37: ", "Valid $LastChangedBy: ", author, " $, started expanded.", NULL); expect[38 - 1] = apr_pstrcat(pool, "Line 38: ", "Valid $Author: ", author, " $, started expanded.", NULL); expect[71 - 1] = apr_pstrcat(pool, ".$veR$Author: ", author, " $", NULL); expect[74 - 1] = apr_pstrcat(pool, "Line 74: ", "Valid $Author: ", author, " $, started expanded.", NULL); expect[79 - 1] = apr_pstrcat(pool, "Line 79: ", "Valid $Author: ", author, " $, started expanded.", NULL); expect[80 - 1] = apr_pstrcat(pool, "Line 80: ", "Valid $Author: ", author, " $, started expanded.", NULL); expect[81 - 1] = apr_pstrcat(pool, "Line 81: ", "Valid $Author: ", author, " $, started expanded.", NULL); expect[82 - 1] = apr_pstrcat(pool, "Line 82: ", "Valid $Author: ", author, " $, started expanded.", NULL); } else /* unexpand */ { /* Lines 8, 9, and 71 remain unchanged. */ expect[37 - 1] = "Line 37: Valid $LastChangedBy$, started expanded."; expect[38 - 1] = "Line 38: Valid $Author$, started expanded."; expect[74 - 1] = "Line 74: Valid $Author$, started expanded."; expect[79 - 1] = "Line 79: Valid $Author$, started expanded."; expect[80 - 1] = "Line 80: Valid $Author$, started expanded."; expect[81 - 1] = "Line 81: Valid $Author$, started expanded."; expect[82 - 1] = "Line 82: Valid $Author$, started expanded."; } } if (url) { if (expand) { expect[16 - 1] = apr_pstrcat(pool, "Line 16: ", "Valid $HeadURL: ", url, " $, started unexpanded.", NULL); expect[17 - 1] = apr_pstrcat(pool, "Line 17: ", "Valid $URL: ", url, " $, started unexpanded.", NULL); expect[41 - 1] = apr_pstrcat(pool, "Line 41: ", "Valid $HeadURL: ", url, " $, started expanded.", NULL); expect[42 - 1] = apr_pstrcat(pool, "Line 42: ", "Valid $URL: ", url, " $, started expanded.", NULL); expect[75 - 1] = apr_pstrcat(pool, "Line 75: ", "Valid $URL: ", url, " $, started expanded.", NULL); } else /* unexpand */ { /* Lines 16 and 17 and remain unchanged. */ expect[41 - 1] = "Line 41: Valid $HeadURL$, started expanded."; expect[42 - 1] = "Line 42: Valid $URL$, started expanded."; expect[75 - 1] = "Line 75: Valid $URL$, started expanded."; } } if (rev) { if (expand) { expect[46 - 1] = apr_pstrcat(pool, "Line 46: ", "Valid $Rev: ", rev, " $ is missing a space.", NULL); } /* Else Line 46 remains unchanged. */ } /* Handle lines 48, 49, and 70 specially, as they contains two valid keywords. */ if (rev && author) { if (expand) { expect[48 - 1] = apr_pstrcat(pool, "Line 48: ", "Two keywords back to back: " "$Author: ", author, " $" "$Rev: ", rev, " $.", NULL); expect[49 - 1] = apr_pstrcat(pool, "Line 49: ", "One keyword, one not, back to back: " "$Author: ", author, " $Rev$.", NULL); expect[70 - 1] = apr_pstrcat(pool, "$Author: ", author, " $Rev$.", NULL); } /* Else Lines 48, 49, and 70 remain unchanged. */ } else if (rev && (! author)) { if (expand) { expect[48 - 1] = apr_pstrcat(pool, "Line 48: ", "Two keywords back to back: " "$Author$$Rev: ", rev, " $.", NULL); expect[49 - 1] = apr_pstrcat(pool, "Line 49: ", "One keyword, one not, back to back: " "$Author$Rev: ", rev, " $.", NULL); expect[70 - 1] = apr_pstrcat(pool, "$Author$Rev: ", rev, " $.", NULL); } /* Else Lines 48, 49, and 70 remain unchanged. */ } else if ((! rev) && author) { if (expand) { expect[48 - 1] = apr_pstrcat(pool, "Line 48: ", "Two keywords back to back: " "$Author: ", author, " $$Rev$.", NULL); expect[49 - 1] = apr_pstrcat(pool, "Line 49: ", "One keyword, one not, back to back: " "$Author: ", author, " $Rev$.", NULL); expect[70 - 1] = apr_pstrcat(pool, "$Author: ", author, " $Rev$.", NULL); } /* Else Lines 48, 49, and 70 remain unchanged. */ } /* Else neither rev nor author, so Lines 48, 49, and 70 remain unchanged. */ /* Handle line 24 specially, as it contains two valid keywords. */ if (date && author) { if (expand) { expect[24 - 1] = apr_pstrcat(pool, "Line 24: ", "keyword in a keyword: $Author: ", author, " $Date$ $", NULL); } else /* unexpand */ { expect[24 - 1] = apr_pstrcat(pool, "Line 24: ", "keyword in a keyword: $Author$Date$ $", NULL); } } else if (date && (! author)) { if (expand) { expect[24 - 1] = apr_pstrcat(pool, "Line 24: ", "keyword in a keyword: $Author: $Date: ", date, " $ $", NULL); } /* Else Line 24 remains unchanged. */ } else if ((! date) && author) { if (expand) { expect[24 - 1] = apr_pstrcat(pool, "Line 24: ", "keyword in a keyword: $Author: ", author, " $Date$ $", NULL); } else /* unexpand */ { expect[24 - 1] = apr_pstrcat(pool, "Line 24: ", "keyword in a keyword: $Author$Date$ $", NULL); } } /* Else neither author nor date, so Line 24 remains unchanged. */ /** Ready to verify. **/ SVN_ERR(svn_stringbuf_from_file(&contents, dst_fname, pool)); for (i = 0; i < (sizeof(expect) / sizeof(*expect)); i++) { if (contents->len < idx) return svn_error_createf (SVN_ERR_MALFORMED_FILE, NULL, "'%s' has short contents at line %" APR_SIZE_T_FMT, dst_fname, i + 1); if (strncmp(contents->data + idx, expect[i], strlen(expect[i])) != 0) return svn_error_createf (SVN_ERR_MALFORMED_FILE, NULL, "'%s' has wrong contents at line %" APR_SIZE_T_FMT, dst_fname, i + 1); /* Else, the data is correct, at least up to the next eol. */ idx += strlen(expect[i]); if (dst_eol) /* verify the promised consistent eol style */ { if (strncmp(contents->data + idx, dst_eol, strlen(dst_eol)) != 0) return svn_error_createf (SVN_ERR_IO_UNKNOWN_EOL, NULL, "'%s' has wrong eol style at line %" APR_SIZE_T_FMT, dst_fname, i + 1); else idx += strlen(dst_eol); } else /* allow any eol style, even inconsistent ones, loosely */ { while ((*(contents->data + idx) == '\r') || (*(contents->data + idx) == '\n')) idx++; } } /* Clean up this test, since successful. */ SVN_ERR(remove_file(src_fname, pool)); SVN_ERR(remove_file(dst_fname, pool)); return SVN_NO_ERROR;}static svn_error_t *noop(const char **msg, svn_boolean_t msg_only, svn_test_opts_t *opts, apr_pool_t *pool){ *msg = "no conversions"; if (msg_only) return SVN_NO_ERROR; SVN_ERR(substitute_and_verify ("noop", NULL, NULL, 0, NULL, NULL, NULL, NULL, 1, pool)); SVN_ERR(substitute_and_verify ("noop", "\r", NULL, 0, NULL, NULL, NULL, NULL, 1, pool)); SVN_ERR(substitute_and_verify ("noop", "\n", NULL, 0, NULL, NULL, NULL, NULL, 1, pool)); SVN_ERR(substitute_and_verify ("noop", "\r\n", NULL, 0, NULL, NULL, NULL, NULL, 1, pool)); return SVN_NO_ERROR;}/** EOL conversion alone. **/static svn_error_t *crlf_to_crlf(const char **msg, svn_boolean_t msg_only, svn_test_opts_t *opts, apr_pool_t *pool){ *msg = "convert CRLF to CRLF"; if (msg_only) return SVN_NO_ERROR; SVN_ERR(substitute_and_verify ("crlf_to_crlf", "\r\n", "\r\n", 0, NULL, NULL, NULL, NULL, 1, pool)); return SVN_NO_ERROR;}static svn_error_t *lf_to_crlf(const char **msg, svn_boolean_t msg_only, svn_test_opts_t *opts, apr_pool_t *pool){ *msg = "convert LF to CRLF"; if (msg_only) return SVN_NO_ERROR; SVN_ERR(substitute_and_verify ("lf_to_crlf", "\n", "\r\n", 0, NULL, NULL, NULL, NULL, 1, pool)); return SVN_NO_ERROR;}static svn_error_t *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -