]> git.saurik.com Git - wxWidgets.git/blame_incremental - tests/html/htmlparser.cpp
proper default for iphone
[wxWidgets.git] / tests / html / htmlparser.cpp
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/html/htmlparser.cpp
3// Purpose: wxHtmlParser tests
4// Author: Vadim Zeitlin
5// Created: 2011-01-13
6// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7///////////////////////////////////////////////////////////////////////////////
8
9// ----------------------------------------------------------------------------
10// headers
11// ----------------------------------------------------------------------------
12
13#include "testprec.h"
14
15#if wxUSE_HTML
16
17#ifdef __BORLANDC__
18 #pragma hdrstop
19#endif
20
21#ifndef WX_PRECOMP
22#endif // WX_PRECOMP
23
24#include "wx/html/htmlpars.h"
25
26// ----------------------------------------------------------------------------
27// test class
28// ----------------------------------------------------------------------------
29
30class HtmlParserTestCase : public CppUnit::TestCase
31{
32public:
33 HtmlParserTestCase() { }
34
35private:
36 CPPUNIT_TEST_SUITE( HtmlParserTestCase );
37 CPPUNIT_TEST( Invalid );
38 CPPUNIT_TEST_SUITE_END();
39
40 void Invalid();
41
42 wxDECLARE_NO_COPY_CLASS(HtmlParserTestCase);
43};
44
45// register in the unnamed registry so that these tests are run by default
46CPPUNIT_TEST_SUITE_REGISTRATION( HtmlParserTestCase );
47
48// also include in its own registry so that these tests can be run alone
49CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HtmlParserTestCase, "HtmlParserTestCase" );
50
51// ----------------------------------------------------------------------------
52// tests themselves
53// ----------------------------------------------------------------------------
54
55// Test that parsing invalid HTML simply fails but doesn't crash for example.
56void HtmlParserTestCase::Invalid()
57{
58 class NullParser : public wxHtmlParser
59 {
60 public:
61 virtual wxObject *GetProduct() { return NULL; }
62
63 protected:
64 virtual void AddText(const wxString& WXUNUSED(txt)) { }
65 };
66
67 NullParser p;
68 p.Parse("<");
69 p.Parse("<foo");
70 p.Parse("<!--");
71 p.Parse("<!---");
72}
73
74#endif //wxUSE_HTML