Skip to content

Commit

Permalink
Failing text parse case.
Browse files Browse the repository at this point in the history
  • Loading branch information
saulius committed Dec 13, 2012
1 parent f5c4bcb commit 69f38ba
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions test/sax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def text(value)
def end_element(name)
@calls << [:end_element, name]
end

def error(message, line, column)
@calls << [:error, message, line, column]
end
Expand Down Expand Up @@ -122,7 +122,7 @@ def parse_compare(xml, expected, handler_class=AllSax, special=false)
end
assert_equal(expected, handler.calls)
end

def test_sax_instruct_simple
parse_compare(%{<?xml?>}, [[:instruct, 'xml'],
[:end_instruct, 'xml']])
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_sax_element_simple
end

def test_sax_element_attrs
parse_compare(%{<top x="57" y='42' z=33 />},
parse_compare(%{<top x="57" y='42' z=33 />},
[[:start_element, :top],
[:attr, :x, "57"],
[:attr, :y, "42"],
Expand Down Expand Up @@ -310,6 +310,14 @@ def test_sax_special
], AllSax, true)
end

def test_sax_whitespace
parse_compare(%{<top> This is some text.</top>},
[[:start_element, :top],
[:text, " This is some text."],
[:end_element, :top]
])
end

def test_sax_text_no_term
parse_compare(%{<top>This is some text.},
[[:start_element, :top],
Expand Down Expand Up @@ -344,7 +352,7 @@ def test_sax_doctype_bad_order
[:error, "invalid format, DOCTYPE can not come after an element", 3, 11],
[:doctype, ' top PUBLIC "top.dtd"']])
end

def test_sax_comment
parse_compare(%{<?xml version="1.0"?>
<!--First comment.-->
Expand Down Expand Up @@ -401,7 +409,7 @@ def test_sax_cdata_no_term
[:start_element, :top],
[:error, "invalid format, cdata terminated unexpectedly", 5, 1]])
end

def test_sax_cdata_empty
parse_compare(%{<?xml version="1.0"?>
<top>
Expand Down

1 comment on commit 69f38ba

@ohler55
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that since the regular parser keep the white space now the sax parser should too.

Please sign in to comment.