forked from github/server
fix overly long lines in NR.
This commit is contained in:
parent
3f9331cd09
commit
2e79c51d00
2 changed files with 27 additions and 1 deletions
|
@ -1440,7 +1440,12 @@ void pump_paragraph(sbstring *sbp, stream *out, size_t maxlen, bool isfinal)
|
|||
char *next = strchr(pos+1, ' ');
|
||||
if (next == NULL) {
|
||||
if (isfinal) {
|
||||
swrite(begin, 1, sbp->end - begin, out);
|
||||
swrite(begin, 1, pos - begin, out);
|
||||
while (*pos && IS_UTF8_SPACE(pos)) {
|
||||
++pos;
|
||||
}
|
||||
newline(out);
|
||||
swrite(pos, 1, sbp->end - pos, out);
|
||||
newline(out);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -379,11 +379,32 @@ static void test_write_spell_syntax(CuTest *tc) {
|
|||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_pump_paragraph_toolong(CuTest *tc) {
|
||||
const char *toolong = "die Ebene von Godsettova (94,-304) und im Westen das Hochland von Geraldin (93,-303).";
|
||||
const char *expect = "die Ebene von Godsettova (94,-304) und im Westen das Hochland von Geraldin\n(93,-303).\n";
|
||||
sbstring sbs;
|
||||
char buf[256];
|
||||
stream out = { 0 };
|
||||
size_t len;
|
||||
|
||||
mstream_init(&out);
|
||||
|
||||
sbs_init(&sbs, buf, sizeof(buf));
|
||||
sbs_strcat(&sbs, toolong);
|
||||
|
||||
pump_paragraph(&sbs, &out, 78, true);
|
||||
out.api->rewind(out.handle);
|
||||
len = out.api->read(out.handle, buf, sizeof(buf));
|
||||
buf[len] = '\0';
|
||||
CuAssertStrEquals(tc, expect, buf);
|
||||
}
|
||||
|
||||
CuSuite *get_report_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_write_spaces);
|
||||
SUITE_ADD_TEST(suite, test_write_many_spaces);
|
||||
SUITE_ADD_TEST(suite, test_pump_paragraph_toolong);
|
||||
SUITE_ADD_TEST(suite, test_report_travelthru);
|
||||
SUITE_ADD_TEST(suite, test_report_region);
|
||||
SUITE_ADD_TEST(suite, test_report_allies);
|
||||
|
|
Loading…
Reference in a new issue