summaryrefslogtreecommitdiff
path: root/test/rdoc/test_rdoc_markup_to_html.rb
blob: b611b768a3596d05001f4a86075353e5a110148d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'rubygems'
require 'minitest/unit'
require 'rdoc/markup'
require 'rdoc/markup/to_html'

class TestRDocMarkupToHtml < MiniTest::Unit::TestCase

  def setup
    @am = RDoc::Markup::AttributeManager.new
    @th = RDoc::Markup::ToHtml.new
  end

  def test_tt_formatting
    assert_equal "<p>\n<tt>--</tt> &#8212; <tt>cats'</tt> cats&#8217;\n</p>\n",
                 util_format("<tt>--</tt> -- <tt>cats'</tt> cats'")
    assert_equal "<p>\n<b>&#8212;</b>\n</p>\n", util_format("<b>--</b>")
  end

  def test_convert_string_fancy
    #
    # The HTML typesetting is broken in a number of ways, but I have fixed
    # the most glaring issues for single and double quotes.  Note that
    # "strange" symbols (periods or dashes) need to be at the end of the
    # test case strings in order to suppress cross-references.
    #
    assert_equal "<p>\n&#8220;cats&#8221;.\n</p>\n", util_format("\"cats\".")
    assert_equal "<p>\n&#8216;cats&#8217;.\n</p>\n", util_format("\'cats\'.")
    assert_equal "<p>\ncat&#8217;s-\n</p>\n", util_format("cat\'s-")
  end

  def util_fragment(text)
    RDoc::Markup::Fragment.new 0, nil, nil, text
  end

  def util_format(text)
    fragment = util_fragment text

    @th.start_accepting
    @th.accept_paragraph @am, fragment
    @th.end_accepting
  end

end

MiniTest::Unit.autorun