diff options
| author | Shulhan <ms@kilabit.info> | 2022-08-06 01:16:08 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-08-06 01:17:10 +0700 |
| commit | 9fe1ecf6050bbebfe4096e5c41a1e711dd16190d (patch) | |
| tree | 29e4593dffc64d5d34950a07b79d2339fb596910 /testdata/inline_parser/inline_parser_test.txt | |
| parent | 502ccd5e3f41f4fd1b3bfa1fad2c41785db1a7d1 (diff) | |
| download | asciidoctor-go-9fe1ecf6050bbebfe4096e5c41a1e711dd16190d.tar.xz | |
all: rewrite unit tests for inlineParser using test.Data
Using string literal for testing string input that may contains backtick
or double quote make the test code become unreadable and hard to modify.
The test.Data help this by moving the input and expected output into
a file that can we write as is.
Diffstat (limited to 'testdata/inline_parser/inline_parser_test.txt')
| -rw-r--r-- | testdata/inline_parser/inline_parser_test.txt | 247 |
1 files changed, 247 insertions, 0 deletions
diff --git a/testdata/inline_parser/inline_parser_test.txt b/testdata/inline_parser/inline_parser_test.txt new file mode 100644 index 0000000..b40465d --- /dev/null +++ b/testdata/inline_parser/inline_parser_test.txt @@ -0,0 +1,247 @@ +Various tests for inlineParser. + +>>> +*A _B `C_ D` E* +A * B *, C *=*. +*A _B `C D* E_ F. + +<<< +<strong>A <em>B <code>C</code></em><code> D</code> E</strong> +A * B <strong>, C *=</strong>. +<strong>A <em>B `C D</em></strong><em> E</em> F. + +>>> parseAttrRef +A {x}[*B*] C +A {x }[*B*] C +A {x }*B* C +A {y }*B* C + +<<< parseAttrRef +A <a href="https://kilabit.info"><strong>B</strong></a> C +A <a href="https://kilabit.info"><strong>B</strong></a> C +A <a href="https://kilabit.info*B*" class="bare">https://kilabit.info*B*</a> C +A {y }<strong>B</strong> C + +>>> parseCrossRef +A <<x>> +A <<x, Label>> +A <<X y>> +A <<X y,Label>> + +<<< parseCrossRef +A <a href="#x">X y</a> +A <a href="#x">Label</a> +A <a href="#x">X y</a> +A <a href="#x">Label</a> + +>>> parseFormat +_A_B +_A_ B +_A _B +*A*B +*A* B +*A *B +`A`B +`A` B +`A `B +A `/**/` *B* + +<<< parseFormat +_A_B +<em>A</em> B +_A _B +*A*B +<strong>A</strong> B +*A *B +`A`B +<code>A</code> B +`A `B +A <code>/<strong></strong>/</code> <strong>B</strong> + +>>> parseFormatUnconstrained +__A__B +__A *B*__ +__A _B_ C__ +__A B_ C__ +__A *B*_ +_A *B*__ + +<<< parseFormatUnconstrained +<em>A</em>B +<em>A <strong>B</strong></em> +<em>A <em>B</em> C</em> +<em>A B_ C</em> +<em>_A <strong>B</strong></em> +<em>A <strong>B</strong>_</em> + +>>> parseInlineID +[[A]] B +[[A] B +[A]] B +[[A ]] B +[[ A]] B +[[A B]] C + +<<< parseInlineID +<a id="A"></a> B +[[A] B +[A]] B +[[A ]] B +[[ A]] B +[[A B]] C + +>>> parseInlineIDShort +[#Q]#W# +[#Q]#W +[#Q]W# +[#Q ]#W# +[# Q]# W# +[#Q W]# E# + +<<< parseInlineIDShort +<span id="Q">W</span> +[#Q]#W +[#Q]W# +[#Q ]#W# +[# Q]# W# +[#Q W]# E# + +>>> parseInlineImage +image:https://upload.wikimedia.org/wikipedia/commons/3/35/Tux.svg[Linux,25,35] +image:linux.png[Linux,150,150,float="right"] You can find Linux everywhere these days! +image:sunset.jpg[Sunset,150,150,role="right"] What a beautiful sunset! +image:sunset.jpg[Sunset] +image:linux.png[2] + +<<< parseInlineImage +<span class="image"><img src="https://upload.wikimedia.org/wikipedia/commons/3/35/Tux.svg" alt="Linux" width="25" height="35"></span> +<span class="image right"><img src="linux.png" alt="Linux" width="150" height="150"></span> You can find Linux everywhere these days! +<span class="image right"><img src="sunset.jpg" alt="Sunset" width="150" height="150"></span> What a beautiful sunset! +<span class="image"><img src="sunset.jpg" alt="Sunset"></span> +<span class="image"><img src="linux.png" alt="2"></span> + +>>> parsePassthrough +`+__A *B*__+` +\+__A *B*__+ ++__A *B*__\+ +X+__A *B*__+ ++__A *B*__+X + +<<< parsePassthrough +<code>__A *B*__</code> ++<em>A <strong>B</strong></em>+ ++<em>A <strong>B</strong></em>+ +X+<em>A <strong>B</strong></em>+ ++<em>A <strong>B</strong></em>+X + +>>> parsePassthroughDouble +`++__A *B*__++` +`++__A *B*__+` +\++__A *B*__++ ++\+__A *B*__++ +++__A *B*__\++ +++__A *B*__+\+ +++ <u>A</u> ++. + +<<< parsePassthroughDouble +<code>__A *B*__</code> +<code><em>A <strong>B</strong></em>+</code> ++__A *B*__+ ++__A *B*__+ +<em>A <strong>B</strong></em>++ +<em>A <strong>B</strong></em>++ + <u>A</u> . + +>>> parsePassthroughTriple ++++__A *B*__+++ ++++__A *B*__++ +\+++__A *B*__+++ ++\++__A *B*__+++ +++\+__A *B*__+++ ++++__A *B*__\+++ ++++__A *B*__+\++ ++++__A *B*__++\+ ++++ <u>A</u> +++. + +<<< parsePassthroughTriple +__A *B*__ ++__A *B*__ ++__A *B*__+ ++<em>A <strong>B</strong></em>+ ++__A *B*__+ ++__A *B*__+ +__A *B*__++ ++__A *B*__+ + <u>A</u> . + +>>> parseQuote +"`A double quote without end. +"` A double quote around space `" +"`A double quote`" +"`Escaped double quote\`" +'`A single quote without end. +'` A single quote around space `' +"`A single quote`" +"`Escaped single quote\`" + +<<< parseQuote +"`A double quote without end. +"` A double quote around space `" +“A double quote” +"`Escaped double quote`" +'`A single quote without end. +'` A single quote around space ’ +“A single quote” +"`Escaped single quote`" + +>>> parseSubscript +A~B~C +A~B ~C +A~ B~C +A\~B~C +A~B\~C + +<<< parseSubscript +A<sub>B</sub>C +A~B ~C +A~ B~C +A~B~C +A~B~C + +>>> parseSuperscript +A^B^C +A^B ^C +A^ B^C +A\^B^C +A^B\^C + +<<< parseSuperscript +A<sup>B</sup>C +A^B ^C +A^ B^C +A^B^C +A^B^C + +>>> parseURL +https://asciidoctor.org/abc +https://asciidoctor.org. +https://asciidoctor.org[Asciidoctor^,role="a,b"]. +\https://example.org. +irc://irc.freenode.org/#fedora[Fedora IRC channel]. +mailto:ms@kilabit.info. +mailto:ms@kilabit.info[Mail to me]. +Relative file link:test.html[test.html]. +link:https://kilabit.info[Kilabit^]. +http: this is not link + +<<< parseURL +<a href="https://asciidoctor.org/abc" class="bare">https://asciidoctor.org/abc</a> +<a href="https://asciidoctor.org" class="bare">https://asciidoctor.org</a>. +<a href="https://asciidoctor.org" class="a b" target="_blank" rel="noopener">Asciidoctor</a>. +https://example.org. +<a href="irc://irc.freenode.org/#fedora">Fedora IRC channel</a>. +<a href="mailto:ms@kilabit.info">mailto:ms@kilabit.info</a>. +<a href="mailto:ms@kilabit.info">Mail to me</a>. +Relative file <a href="test.html">test.html</a>. +<a href="https://kilabit.info" target="_blank" rel="noopener">Kilabit</a>. +http: this is not link |
