File: test-block-parser.rb

package info (click to toggle)
rdtool 0.6.38-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 940 kB
  • sloc: ruby: 8,213; lisp: 387; sh: 33; makefile: 16
file content (46 lines) | stat: -rwxr-xr-x 1,456 bytes parent folder | download | duplicates (9)
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
46
require 'test/unit'

require 'rd/rdblockparser.tab'
require 'rd/rd-struct'

include RD

class TestBlockParser < Test::Unit::TestCase
  def setup
    @p = RDParser.new
    @p.class.module_eval {
      public :cut_off,:set_term_to_element
    }
    @p.instance_eval do
      @tree = Tree.new_with_document_struct(DocumentStructure::RD)
    end
  end
  
  def test_cut_off
    assert_equal(["aaaa"], @p.cut_off(["aaaa"]))
    assert_equal(["aaaa\n"], @p.cut_off(["aaaa\n"]))
    assert_equal(["aaaa\n"], @p.cut_off(["  aaaa\n"]))
    assert_equal(["aaaa\n", "bbbb\n"], @p.cut_off(["  aaaa\n", "  bbbb\n"]))
    assert_equal(["aaaa\n", "  bbbb\n"], @p.cut_off(["aaaa\n", "  bbbb\n"]))
    assert_equal(["aaaa\n", "  bbbb\n"], @p.cut_off([" aaaa\n", "   bbbb\n"]))
    assert_equal(["aaaa\n", "  bbbb\n", "    cccc\n"],
                 @p.cut_off([" aaaa\n", "   bbbb\n", "     cccc\n"]))
    assert_equal(["aaaa\n", "    bbbb\n", "  cccc\n"],
                 @p.cut_off([" aaaa\n", "     bbbb\n", "   cccc\n"]))
    assert_raises(RuntimeError) do
      @p.cut_off(["  aaaa\n", "bbbb\n"])
    end
  end

  def test_set_term_to_element
    desclist = DescListItem.new
    term = DescListItem::Term.new
    @p.set_term_to_element(desclist, term)
    assert_equal(term, desclist.term)

    methodlist = MethodListItem.new
    term = MethodListItem::Term.new "string"
    @p.set_term_to_element(methodlist, term)
    assert_equal(term, methodlist.term)
  end
end