Fix memory leaks in wxHtmlParser unit test
Remove the unnecessary, and actually harmful, overridden GetProduct(), as we must delete the pointer returned by the base class version to avoid leaking it. Also use wxScopedPtr to avoid leaking a test wxHtmlContainerCell.
This commit is contained in:
parent
413c05ea85
commit
02f697d0c0
@ -20,15 +20,13 @@
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/html/winpars.h"
|
||||
#include "wx/scopedptr.h"
|
||||
|
||||
// Test that parsing invalid HTML simply fails but doesn't crash for example.
|
||||
TEST_CASE("wxHtmlParser::ParseInvalid", "[html][parser][error]")
|
||||
{
|
||||
class NullParser : public wxHtmlWinParser
|
||||
{
|
||||
public:
|
||||
virtual wxObject *GetProduct() wxOVERRIDE { return NULL; }
|
||||
|
||||
protected:
|
||||
virtual void AddText(const wxString& WXUNUSED(txt)) wxOVERRIDE { }
|
||||
};
|
||||
@ -37,17 +35,17 @@ TEST_CASE("wxHtmlParser::ParseInvalid", "[html][parser][error]")
|
||||
wxMemoryDC dc;
|
||||
p.SetDC(&dc);
|
||||
|
||||
p.Parse("<");
|
||||
p.Parse("<foo");
|
||||
p.Parse("<!--");
|
||||
p.Parse("<!---");
|
||||
delete p.Parse("<");
|
||||
delete p.Parse("<foo");
|
||||
delete p.Parse("<!--");
|
||||
delete p.Parse("<!---");
|
||||
}
|
||||
|
||||
TEST_CASE("wxHtmlCell::Detach", "[html][cell]")
|
||||
{
|
||||
wxMemoryDC dc;
|
||||
|
||||
wxHtmlContainerCell* const top = new wxHtmlContainerCell(NULL);
|
||||
wxScopedPtr<wxHtmlContainerCell> const top(new wxHtmlContainerCell(NULL));
|
||||
wxHtmlContainerCell* const cont = new wxHtmlContainerCell(NULL);
|
||||
wxHtmlCell* const cell1 = new wxHtmlWordCell("Hello", dc);
|
||||
wxHtmlCell* const cell2 = new wxHtmlColourCell(*wxRED);
|
||||
|
Loading…
Reference in New Issue
Block a user