public void noErrorsByDefault() { string html = "<p>One</p href='no'>&arrgh;<font /><br /><foo"; NSoup.Parse.Parser parser = NSoup.Parse.Parser.HtmlParser(); Document doc = NSoupClient.Parse(html, "http://example.com", parser); List <ParseError> errors = parser.GetErrors(); Assert.AreEqual(0, errors.Count); }
public void tracksLimitedErrorsWhenRequested() { string html = "<p>One</p href='no'><!DOCTYPE html>&arrgh;<font /><br /><foo"; NSoup.Parse.Parser parser = NSoup.Parse.Parser.HtmlParser().SetTrackErrors(3); Document doc = parser.ParseInput(html, "http://example.com"); List <ParseError> errors = parser.GetErrors(); Assert.AreEqual(3, errors.Count); Assert.AreEqual("20: Attributes incorrectly present on end tag", errors[0].ToString()); Assert.AreEqual("35: Unexpected token [Doctype] when in state [InBody]", errors[1].ToString()); Assert.AreEqual("36: Invalid character reference: Invalid named referenece 'arrgh'", errors[2].ToString()); }
public void tracksErrorsWhenRequested() { string html = "<p>One</p href='no'><!DOCTYPE html>&arrgh;<font /><br /><foo"; NSoup.Parse.Parser parser = NSoup.Parse.Parser.HtmlParser().SetTrackErrors(500); Document doc = NSoupClient.Parse(html, "http://example.com", parser); List <ParseError> errors = parser.GetErrors(); Assert.AreEqual(5, errors.Count); Assert.AreEqual("20: Attributes incorrectly present on end tag", errors[0].ToString()); Assert.AreEqual("35: Unexpected token [Doctype] when in state [InBody]", errors[1].ToString()); Assert.AreEqual("36: Invalid character reference: Invalid named referenece 'arrgh'", errors[2].ToString()); Assert.AreEqual("50: Self closing flag not acknowledged", errors[3].ToString()); Assert.AreEqual("61: Unexpectedly reached end of file (EOF) in input state [TagName]", errors[4].ToString()); }