From 9fe1ecf6050bbebfe4096e5c41a1e711dd16190d Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 6 Aug 2022 01:16:08 +0700 Subject: 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. --- testdata/inline_parser/inline_parser_test.txt | 247 ++++++++++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 testdata/inline_parser/inline_parser_test.txt (limited to 'testdata/inline_parser/inline_parser_test.txt') 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. + +<<< +A B C D E +A * B , C *=. +A B `C D E F. + +>>> parseAttrRef +A {x}[*B*] C +A {x }[*B*] C +A {x }*B* C +A {y }*B* C + +<<< parseAttrRef +A B C +A B C +A https://kilabit.info*B* C +A {y }B C + +>>> parseCrossRef +A <> +A <> +A <> +A <> + +<<< parseCrossRef +A X y +A Label +A X y +A Label + +>>> parseFormat +_A_B +_A_ B +_A _B +*A*B +*A* B +*A *B +`A`B +`A` B +`A `B +A `/**/` *B* + +<<< parseFormat +_A_B +A B +_A _B +*A*B +A B +*A *B +`A`B +A B +`A `B +A // B + +>>> parseFormatUnconstrained +__A__B +__A *B*__ +__A _B_ C__ +__A B_ C__ +__A *B*_ +_A *B*__ + +<<< parseFormatUnconstrained +AB +A B +A B C +A B_ C +_A B +A B_ + +>>> parseInlineID +[[A]] B +[[A] B +[A]] B +[[A ]] B +[[ A]] B +[[A B]] C + +<<< parseInlineID + 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 +W +[#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 +Linux +Linux You can find Linux everywhere these days! +Sunset What a beautiful sunset! +Sunset +2 + +>>> parsePassthrough +`+__A *B*__+` +\+__A *B*__+ ++__A *B*__\+ +X+__A *B*__+ ++__A *B*__+X + +<<< parsePassthrough +__A *B*__ ++A B+ ++A B+ +X+A B+ ++A B+X + +>>> parsePassthroughDouble +`++__A *B*__++` +`++__A *B*__+` +\++__A *B*__++ ++\+__A *B*__++ +++__A *B*__\++ +++__A *B*__+\+ +++ A ++. + +<<< parsePassthroughDouble +__A *B*__ +A B+ ++__A *B*__+ ++__A *B*__+ +A B++ +A B++ + A . + +>>> parsePassthroughTriple ++++__A *B*__+++ ++++__A *B*__++ +\+++__A *B*__+++ ++\++__A *B*__+++ +++\+__A *B*__+++ ++++__A *B*__\+++ ++++__A *B*__+\++ ++++__A *B*__++\+ ++++ A +++. + +<<< parsePassthroughTriple +__A *B*__ ++__A *B*__ ++__A *B*__+ ++A B+ ++__A *B*__+ ++__A *B*__+ +__A *B*__++ ++__A *B*__+ + A . + +>>> 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 +ABC +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 +ABC +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 +https://asciidoctor.org/abc +https://asciidoctor.org. +Asciidoctor. +https://example.org. +Fedora IRC channel. +mailto:ms@kilabit.info. +Mail to me. +Relative file test.html. +Kilabit. +http: this is not link -- cgit v1.3-6-g1900