Class: ODDB::ChapterParse::TestParserGecko

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
ext/chapterparse/test/test_parser.rb

Defined Under Namespace

Classes: Formatter

Instance Method Summary collapse

Instance Method Details

#setupObject



29
30
31
32
# File 'ext/chapterparse/test/test_parser.rb', line 29

def setup
	@formatter = Formatter.new
	@parser = Parser.new(@formatter)
end

#test_parse__bObject



33
34
35
36
37
38
39
40
41
# File 'ext/chapterparse/test/test_parser.rb', line 33

def test_parse__b
src = <<-EOS
<span style="font-weight: bold;">Acidum
EOS
@parser.feed(src)
assert_equal([[nil, nil, 1, nil]], 
	@formatter.font_stack)
@parser.feed('</span>')
assert_equal([], @formatter.font_stack) end

#test_parse__bbObject



42
43
44
45
46
47
48
49
50
51
# File 'ext/chapterparse/test/test_parser.rb', line 42

def test_parse__bb
	src = <<-EOS
<span bgcolor="#FFFFFF" style="font-weight: bold;font-weight: bold">Acidum
	EOS
	@parser.feed(src)
	assert_equal([[nil, nil, 1, nil]], 
		@formatter.font_stack)
	@parser.feed('</span>')
	assert_equal([], @formatter.font_stack)
end

#test_parse__biObject



62
63
64
65
66
67
68
69
70
71
# File 'ext/chapterparse/test/test_parser.rb', line 62

def test_parse__bi
	src = <<-EOS
<span style="font-weight: bold; font-style: italic;">Eigenschaften/Wirkungen
	EOS
	@parser.feed(src)
	assert_equal([[nil, nil, 1, nil], [nil, 1, nil, nil]],
		@formatter.font_stack)				
	@parser.feed('</span>')
	assert_equal([], @formatter.font_stack)
end

#test_parse__combinedObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'ext/chapterparse/test/test_parser.rb', line 81

def test_parse__combined
	src = <<-EOS
<span style="font-weight: bold;">
  Fett
	EOS
	@parser.feed(src)
	assert_equal([[nil, nil, 1, nil]], 
		@formatter.font_stack)
	src = <<-EOS
  <span style="font-family: courier new,courier,mono;">
Fixed-Width Font
	EOS
	@parser.feed(src)
	assert_equal([[nil, nil, 1, nil], [nil, nil, nil, 1]],
		@formatter.font_stack)
	assert_equal(1, @parser.nofill)
	@parser.feed('</span>')
	assert_equal([[nil, nil, 1, nil]], 
		@formatter.font_stack)
	assert_equal(0, @parser.nofill)
	@parser.feed('</span>')
	assert_equal([], @formatter.font_stack)
	assert_equal(0, @parser.nofill)
end

#test_parse__courierObject



105
106
107
108
109
110
111
112
113
# File 'ext/chapterparse/test/test_parser.rb', line 105

def test_parse__courier
	src=<<-EOS
<span style="font-family: courier new,courier,mono;">Test
	EOS
	@parser.feed(src)
	assert_equal([[nil,nil,nil,1]], @formatter.font_stack)
	@parser.feed("</span>")
	assert_equal([], @formatter.font_stack)
end

#test_parse__div_preformattedObject



114
115
116
117
118
119
120
121
122
# File 'ext/chapterparse/test/test_parser.rb', line 114

def test_parse__div_preformatted
	src=<<-EOS
<div class="preformatted">Test
	EOS
	@parser.feed(src)
	assert_equal([[nil, nil, nil, 1]], @formatter.font_stack)
	@parser.feed("</div>")
	assert_equal([], @formatter.font_stack)
end

#test_parse__fontObject



72
73
74
75
76
77
78
79
80
# File 'ext/chapterparse/test/test_parser.rb', line 72

def test_parse__font
	src = <<-EOS
<span style="font-family: courier new,courier,mono;">Wirkstoff
	EOS
	@parser.feed(src)
	assert_equal(1, @parser.nofill)
	@parser.feed('</span>')
	assert_equal(0, @parser.nofill)
end

#test_parse__iObject



52
53
54
55
56
57
58
59
60
61
# File 'ext/chapterparse/test/test_parser.rb', line 52

def test_parse__i
	src = <<-EOS
<span style="font-style: italic;">mefenamicum
	EOS
	@parser.feed(src)
	assert_equal([[nil, 1, nil, nil]], 
		@formatter.font_stack)
	@parser.feed('</span>')
	assert_equal([], @formatter.font_stack)
end