fixed string length bug

This commit is contained in:
Kyle Maxwell 2009-02-19 00:28:54 -08:00
parent fd0d84b4de
commit be7a05d8ab
2 changed files with 6 additions and 1 deletions

View File

@ -48,7 +48,7 @@ VALUE _parse_string(VALUE self, VALUE string, VALUE input, VALUE output) {
dexPtr dex;
Data_Get_Struct(self, dexPtr, dex);
char* cstr = STR2CSTR(string);
return _parse_doc(dex_parse_string(dex, cstr, strlen(string), input == ID2SYM(rb_intern("html"))), output);
return _parse_doc(dex_parse_string(dex, cstr, strlen(cstr), input == ID2SYM(rb_intern("html"))), output);
}
VALUE _parse_doc(parsedDexPtr ptr, VALUE type) {

View File

@ -11,6 +11,11 @@ class TestDexterous < Test::Unit::TestCase
assert_equal({"hi" => "Nick's Crispy Tacos"}, @dex.parse(:file => @file))
end
def test_simple_string
@dex = Dexterous.new("hi" => "h1")
assert_equal({"hi" => "Nick's Crispy Tacos"}, @dex.parse(:string => "<html><body><h1>Nick's Crispy Tacos</h1></body></html>"))
end
def test_xml
@dex = Dexterous.new("hi" => "h1")
xml = "<?xml version=\"1.0\"?>\n<dexter:root xmlns:dexter=\"http://kylemaxwell.com/dexter\"><hi>Nick's Crispy Tacos</hi></dexter:root>\n"