diff --git a/test/rdoc/end_to_end/heading_test.rb b/test/rdoc/end_to_end/heading_test.rb new file mode 100644 index 0000000000..e7da9940e5 --- /dev/null +++ b/test/rdoc/end_to_end/heading_test.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true +require_relative 'helper' + +class HeadingTest < XrefTestCase + + def test_headings + markup = <') + assert_equal(2, hr_lines.size) + # Check count of not horizontal rules. + # One of the above generates an M-dash, the other an N-dash. + pattern = /

(—|–) Not a horizontal rule.<\/p>/ + not_hr_lines = html_lines.select {|line| line.match(pattern) } + assert_equal(2, not_hr_lines.size) + end + end + +end diff --git a/test/rdoc/end_to_end/text_markup_test.rb b/test/rdoc/end_to_end/text_markup_test.rb new file mode 100644 index 0000000000..b0ebb55429 --- /dev/null +++ b/test/rdoc/end_to_end/text_markup_test.rb @@ -0,0 +1,149 @@ +# frozen_string_literal: true +require_relative 'helper' + +class TextMarkupTest < XrefTestCase + + def test_italic + markup = <>> + Block quote containing _italic_word_. + +- List item containing _italic_word_. + += Heading containing _italic_word_. + +Paragraph containing italic phrase. + +>>> + Block quote containing italic phrase. + +- List item containing italic phrase. + += Heading containing italic phrase. + +Paragraph containing italic phrase. + +>>> + Block quote containing italic phrase. + +- List item containing italic phrase. + += Heading containing italic phrase. + +MARKUP + Helper.run_rdoc(markup, __method__) do |html_lines| + italic_word_lines = Helper.select_lines(html_lines, 'italic_word') + # Check count of italic words. + # (Five, not four, b/c the heading generates two.) + assert_equal(5, italic_word_lines.size) + italic_phrase_lines = Helper.select_lines(html_lines, 'italic phrase') + # Check count of italic phrases. + # (Ten, not eight, b/c each heading generates two.) + assert_equal(10, italic_phrase_lines.size) + end + end + + def test_bold + markup = <>> + Block quote containing *bold_word*. + +- List item containing *bold_word*. + += Heading containing *bold_word*. + +Paragraph containing bold phrase. + +>>> + Block quote containing bold phrase. + +- List item containing bold phrase. + += Heading containing bold phrase. + +MARKUP + Helper.run_rdoc(markup, __method__) do |html_lines| + # Check count of bold words. + bold_word_lines = Helper.select_lines(html_lines, 'bold_word') + # (Five, not four, b/c the heading generates two.) + assert_equal(5, bold_word_lines.size) + # Check count of bold phrases. + bold_phrase_lines = Helper.select_lines(html_lines, 'bold phrase') + # (Five, not four, b/c the heading generates two.) + assert_equal(5, bold_phrase_lines.size) + end + end + + def test_monofont + markup = <>> + Block quote containing +monofont_word+. + +- List item containing +monofont_word+. + += Heading containing +monofont_word+. + +Paragraph containing monofont phrase. + +>>> + Block quote containing monofont phrase. + +- List item containing monofont phrase. + += Heading containing monofont phrase. + +Paragraph containing monofont phrase. + +>>> + Block quote containing monofont phrase. + +- List item containing monofont phrase. + += Heading containing monofont phrase. + +MARKUP + Helper.run_rdoc(markup, __method__) do |html_lines| + monofont_word_lines = Helper.select_lines(html_lines, 'monofont_word') + # Check count of monofont words. + # (Five, not four, b/c the heading generates two.) + assert_equal(5, monofont_word_lines.size) + monofont_phrase_lines = Helper.select_lines(html_lines, 'monofont phrase') + # Check count of monofont phrases. + # (Ten, not eight, b/c each heading generates two.) + assert_equal(10, monofont_phrase_lines.size) + end + end + + def test_character_conversions + convertible_characters = %w[(c) (r) ... -- --- 'foo' "bar"].join(' ') + + markup = <>> + Block quote containing #{convertible_characters}. + +- List item containing #{convertible_characters}. + += Heading containing #{convertible_characters}. + +MARKUP + Helper.run_rdoc(markup, __method__) do |html_lines| + converted_character_lines = Helper.select_lines(html_lines, '© ® … – — ‘foo’ “bar”') + # Check count of converted character lines. + # (The generated heading line contains escapes, and so does not match.) + assert_equal(4, converted_character_lines.size) + end + end + +end