Go to the source code of this file.
Value: MACRO_BEGIN \
EXPECT_TRUE(expect == out); \
LOG_INFO(expect); \
LOG_INFO(out); \
ERASEABLE string markdown(string s)
Handle string spacing as markdown:
Referenced by TEST().
◆ markdown()
Handle string spacing as markdown:
- two spaces escape a linebreak (otherwise text wraps)
- two linebreaks become a paragraph (remain unchanged)
Definition at line 7 of file markdown.qh.
8{
9 string buf = "";
10 int lines = 0;
11 int spaces = 0;
13 {
14 switch (it)
15 {
16 default:
17 for (; spaces > 0; --spaces)
20 break;
21 case ' ':
22 ++spaces;
23 break;
24 case '\n':
25 ++lines;
26 if (lines > 1)
27 {
28 lines = 0;
29 spaces = 0;
31 break;
32 }
33 if (spaces < 2)
34 spaces = 1;
35 else
36 {
37 spaces = 0;
39 }
40 break;
41 }
42 });
43 return buf;
44}
#define FOREACH_CHAR(s, cond, body)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
References chr2str, FOREACH_CHAR, and strcat().
◆ TEST()
| TEST |
( |
Markdown | , |
|
|
LineWrap | ) |
Definition at line 46 of file markdown.qh.
47{
48 #define X(expect, in) MACRO_BEGIN \
49 string out = markdown(in); \
50 EXPECT_TRUE(expect == out); \
51 LOG_INFO(expect); \
52 LOG_INFO(out); \
53 MACRO_END
54
55
56 X(
"lorem ipsum",
"lorem ipsum");
57
58 X(
"lorem ipsum",
"lorem ipsum ");
59
60 X(
"lorem ipsum",
"lorem\nipsum");
61
62 X(
"lorem\nipsum",
"lorem \nipsum");
63
64 X(
"lorem\n\nipsum",
"lorem\n\nipsum");
66 #undef X
67}
#define SUCCEED()
Must be present at the end of a test.
References SUCCEED, and X.