From c8003a0a06798e297e18dbb100cb597cbee2808a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 4 Sep 2026 15:11:54 +0200 Subject: [PATCH] Use make_unique<>() instead of "new" in the tests No real changes, just avoid explicit "new" calls. --- tests/controls/auitest.cpp | 2 +- tests/controls/gridtest.cpp | 2 +- tests/controls/infobar.cpp | 4 +-- tests/controls/label.cpp | 26 +++++++++-------- tests/controls/propgridtest.cpp | 2 +- tests/controls/radioboxtest.cpp | 10 +++---- tests/controls/radiobuttontest.cpp | 46 +++++++++++++++--------------- tests/controls/spinctrldbltest.cpp | 21 ++++++-------- tests/controls/textctrltest.cpp | 40 +++++++++++++------------- tests/controls/windowtest.cpp | 7 ++--- tests/docview/updateallviews.cpp | 2 +- tests/events/enterleave.cpp | 3 +- tests/filesys/filesystest.cpp | 2 +- tests/graphics/clipper.cpp | 4 +-- tests/graphics/clippingbox.cpp | 4 +-- tests/html/htmlparser.cpp | 2 +- tests/misc/guifuncs.cpp | 16 +++++------ tests/net/webrequest.cpp | 4 +-- tests/sizers/boxsizer.cpp | 2 +- tests/sizers/wrapsizer.cpp | 4 +-- tests/streams/largefile.cpp | 4 +-- tests/thread/misc.cpp | 2 +- tests/thread/queue.cpp | 8 +++--- tests/validators/valnum.cpp | 6 ++-- tests/window/clientsize.cpp | 17 ++++++----- tests/window/setsize.cpp | 8 +++--- tests/xml/xmltest.cpp | 4 +-- tests/xml/xrctest.cpp | 2 +- 28 files changed, 125 insertions(+), 129 deletions(-) diff --git a/tests/controls/auitest.cpp b/tests/controls/auitest.cpp index 13f850c653..ad5d4f58f6 100644 --- a/tests/controls/auitest.cpp +++ b/tests/controls/auitest.cpp @@ -514,7 +514,7 @@ TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::Layout", "[aui]") TEST_CASE("wxAuiToolBar::Items", "[aui][toolbar]") { - std::unique_ptr tbar{new wxAuiToolBar(wxTheApp->GetTopWindow())}; + auto tbar = make_unique(wxTheApp->GetTopWindow()); // Check that adding more toolbar elements doesn't invalidate the existing // pointers. diff --git a/tests/controls/gridtest.cpp b/tests/controls/gridtest.cpp index 6e5a696118..7ad8b9bb8c 100644 --- a/tests/controls/gridtest.cpp +++ b/tests/controls/gridtest.cpp @@ -2783,7 +2783,7 @@ TEST_CASE("GridBlockCoords::SymDifference", "[grid]") TEST_CASE("wxGrid::Events", "[grid][event]") { - const std::unique_ptr grid(new wxGrid()); + const auto grid = make_unique(); EventCounter selectEvents(grid.get(), wxEVT_GRID_SELECT_CELL); diff --git a/tests/controls/infobar.cpp b/tests/controls/infobar.cpp index 76c923f586..b3c6bac871 100644 --- a/tests/controls/infobar.cpp +++ b/tests/controls/infobar.cpp @@ -24,8 +24,8 @@ TEST_CASE("wxInfoBar::Buttons", "[wxInfoBar]") { - const std::unique_ptr - info(new wxInfoBar(wxTheApp->GetTopWindow(), wxID_ANY, wxINFOBAR_CHECKBOX)); + const auto info = make_unique(wxTheApp->GetTopWindow(), wxID_ANY, + wxINFOBAR_CHECKBOX); CHECK(info->GetButtonCount() == 0); diff --git a/tests/controls/label.cpp b/tests/controls/label.cpp index c242f8f793..89e1fcd6ba 100644 --- a/tests/controls/label.cpp +++ b/tests/controls/label.cpp @@ -92,38 +92,40 @@ TEST_CASE("wxControl::Label", "[wxControl][label]") { SECTION("wxStaticText") { - const std::unique_ptr - st(new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL)); + const auto st = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, ORIGINAL_LABEL); DoTestLabel(st.get()); } SECTION("wxStaticText/ellipsized") { - const std::unique_ptr - st(new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL, - wxDefaultPosition, wxDefaultSize, - wxST_ELLIPSIZE_START)); + const auto st = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, ORIGINAL_LABEL, + wxDefaultPosition, + wxDefaultSize, + wxST_ELLIPSIZE_START); DoTestLabel(st.get()); } SECTION("wxGenericStaticText") { - const std::unique_ptr - gst(new wxGenericStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL)); + const auto gst = + make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, ORIGINAL_LABEL); DoTestLabel(gst.get()); } SECTION("wxCheckBox") { - const std::unique_ptr - cb(new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL)); + const auto cb = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, ORIGINAL_LABEL); DoTestLabel(cb.get()); } SECTION("wxTextCtrl") { - const std::unique_ptr - tc(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL)); + const auto tc = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, ORIGINAL_LABEL); // Setting the label of a wxTextCtrl should _not_ work, it has value // and not a label. diff --git a/tests/controls/propgridtest.cpp b/tests/controls/propgridtest.cpp index db2f6a0b9b..276a1688f5 100644 --- a/tests/controls/propgridtest.cpp +++ b/tests/controls/propgridtest.cpp @@ -489,7 +489,7 @@ TEST_CASE("PropertyGridTestCase", "[propgrid]") #if defined(__WXGTK__) // Under wxGTK we need to have two children (at least) because if there // is one child its paint area is set to fill the whole parent frame. - std::unique_ptr win0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); + auto win0 = make_unique(wxTheApp->GetTopWindow(), wxID_ANY); #endif // wxGTK std::unique_ptr pgManager(CreateGrid(-1, -1)); diff --git a/tests/controls/radioboxtest.cpp b/tests/controls/radioboxtest.cpp index cc25e59cca..a51a725a20 100644 --- a/tests/controls/radioboxtest.cpp +++ b/tests/controls/radioboxtest.cpp @@ -196,11 +196,11 @@ TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::SetString", "[radiobox]") TEST_CASE("RadioBox::NoItems", "[radiobox]") { - std::unique_ptr - radio(new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "Empty", - wxDefaultPosition, wxDefaultSize, - 0, nullptr, - 1, wxRA_SPECIFY_COLS)); + auto radio = make_unique(wxTheApp->GetTopWindow(), wxID_ANY, + "Empty", + wxDefaultPosition, wxDefaultSize, + 0, nullptr, + 1, wxRA_SPECIFY_COLS); CHECK( radio->GetCount() == 0 ); CHECK( radio->IsEmpty() ); diff --git a/tests/controls/radiobuttontest.cpp b/tests/controls/radiobuttontest.cpp index 65897d50c0..de21f0b2b4 100644 --- a/tests/controls/radiobuttontest.cpp +++ b/tests/controls/radiobuttontest.cpp @@ -89,22 +89,22 @@ TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Group", "[radiobutton]") wxWindow* const parent = wxTheApp->GetTopWindow(); // Create two different radio groups. - std::unique_ptr g1radio0(new wxRadioButton(parent, wxID_ANY, "radio 1.0", - wxDefaultPosition, wxDefaultSize, - wxRB_GROUP)); + auto g1radio0 = make_unique(parent, wxID_ANY, "radio 1.0", + wxDefaultPosition, wxDefaultSize, + wxRB_GROUP); - std::unique_ptr g1radio1(new wxRadioButton(parent, wxID_ANY, "radio 1.1")); + auto g1radio1 = make_unique(parent, wxID_ANY, "radio 1.1"); - std::unique_ptr g2radio0(new wxRadioButton(parent, wxID_ANY, "radio 2.0", - wxDefaultPosition, wxDefaultSize, - wxRB_GROUP)); + auto g2radio0 = make_unique(parent, wxID_ANY, "radio 2.0", + wxDefaultPosition, wxDefaultSize, + wxRB_GROUP); - std::unique_ptr g2radio1(new wxRadioButton(parent, wxID_ANY, "radio 2.1")); + auto g2radio1 = make_unique(parent, wxID_ANY, "radio 2.1"); // Check that having another control between radio buttons doesn't break // grouping. - std::unique_ptr text(new wxStaticText(parent, wxID_ANY, "Label")); - std::unique_ptr g2radio2(new wxRadioButton(parent, wxID_ANY, "radio 2.2")); + auto text = make_unique(parent, wxID_ANY, "Label"); + auto g2radio2 = make_unique(parent, wxID_ANY, "radio 2.2"); g1radio0->SetValue(true); g2radio0->SetValue(true); @@ -174,25 +174,25 @@ TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Group", "[radiobutton]") TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Single", "[radiobutton]") { //Create a group of 2 buttons, having second button selected - std::unique_ptr gradio0(new wxRadioButton(wxTheApp->GetTopWindow(), - wxID_ANY, "wxRadioButton", - wxDefaultPosition, - wxDefaultSize, wxRB_GROUP)); + auto gradio0 = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, "wxRadioButton", + wxDefaultPosition, + wxDefaultSize, wxRB_GROUP); - std::unique_ptr gradio1(new wxRadioButton(wxTheApp->GetTopWindow(), - wxID_ANY, "wxRadioButton")); + auto gradio1 = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, "wxRadioButton"); gradio1->SetValue(true); //Create a "single" button (by default it will not be selected) - std::unique_ptr sradio(new wxRadioButton(wxTheApp->GetTopWindow(), - wxID_ANY, "wxRadioButton", - wxDefaultPosition, - wxDefaultSize, wxRB_SINGLE)); + auto sradio = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, "wxRadioButton", + wxDefaultPosition, + wxDefaultSize, wxRB_SINGLE); //Create a non-grouped button and select it - std::unique_ptr ngradio(new wxRadioButton(wxTheApp->GetTopWindow(), - wxID_ANY, "wxRadioButton")); + auto ngradio = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, "wxRadioButton"); ngradio->SetValue(true); @@ -214,7 +214,7 @@ TEST_CASE("RadioButton::Focus", "[radiobutton][focus]") // Create a container panel just to be able to destroy all the windows // created here at once by simply destroying it. wxWindow* const tlw = wxTheApp->GetTopWindow(); - std::unique_ptr parentPanel(new wxPanel(tlw)); + auto parentPanel = make_unique(tlw); // Create a panel containing 2 radio buttons and another control outside // this panel, so that we could give focus to something different and then diff --git a/tests/controls/spinctrldbltest.cpp b/tests/controls/spinctrldbltest.cpp index 85ef0829aa..70da7ac61c 100644 --- a/tests/controls/spinctrldbltest.cpp +++ b/tests/controls/spinctrldbltest.cpp @@ -52,7 +52,7 @@ TEST_CASE("SpinCtrlDouble::NoEventsInCtor", "[spinctrl][spinctrldouble]") { // Verify that creating the control does not generate any events. This is // unexpected and shouldn't happen. - std::unique_ptr spin(new wxSpinCtrlDouble); + auto spin = make_unique(); EventCounter updatedSpin(spin.get(), wxEVT_SPINCTRLDOUBLE); EventCounter updatedText(spin.get(), wxEVT_TEXT); @@ -258,17 +258,14 @@ TEST_CASE_METHOD(SpinCtrlDoubleTestCase, static inline unsigned int GetInitialDigits(double inc) { - std::unique_ptr sc(new wxSpinCtrlDouble - ( - wxTheApp->GetTopWindow(), - wxID_ANY, - wxEmptyString, - wxDefaultPosition, - wxDefaultSize, - wxSP_ARROW_KEYS, - 0, 50, 0, - inc - )); + auto sc = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, + wxEmptyString, + wxDefaultPosition, + wxDefaultSize, + wxSP_ARROW_KEYS, + 0, 50, 0, + inc); return sc->GetDigits(); } diff --git a/tests/controls/textctrltest.cpp b/tests/controls/textctrltest.cpp index 68e0a640fe..31a5d6430d 100644 --- a/tests/controls/textctrltest.cpp +++ b/tests/controls/textctrltest.cpp @@ -1420,10 +1420,10 @@ TEST_CASE("wxTextCtrl::GetBestSize", "[wxTextCtrl][best-size]") { wxSize operator()(const wxString& text) const { - std::unique_ptr - t(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, text, - wxDefaultPosition, wxDefaultSize, - wxTE_MULTILINE)); + auto t = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, text, + wxDefaultPosition, wxDefaultSize, + wxTE_MULTILINE); return t->GetBestSize(); } } getBestSizeFor; @@ -1489,9 +1489,9 @@ TEST_CASE("wxTextCtrl::LongPaste", "[wxTextCtrl][clipboard][paste]") return; } - std::unique_ptr - text(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, wxString(), - wxDefaultPosition, wxDefaultSize, style)); + auto text = make_unique(wxTheApp->GetTopWindow(), wxID_ANY, + wxString(), wxDefaultPosition, + wxDefaultSize, style); // This could actually be much higher, but it makes the test proportionally // slower, so use a relatively small (but still requiring more space than @@ -1543,7 +1543,7 @@ TEST_CASE("wxTextCtrl::EventsOnCreate", "[wxTextCtrl][event]") EventCounter updated(parent, wxEVT_TEXT); - std::unique_ptr text(new wxTextCtrl(parent, wxID_ANY, "Hello")); + auto text = make_unique(parent, wxID_ANY, "Hello"); // Creating the control shouldn't result in any wxEVT_TEXT events. CHECK( updated.GetCount() == 0 ); @@ -1560,7 +1560,7 @@ TEST_CASE("wxTextCtrl::GTKSetPangoMarkup", "[wxTextCtrl][pango]") { wxWindow* const parent = wxTheApp->GetTopWindow(); - std::unique_ptr text(new wxTextCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE)); + auto text = make_unique(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); text->SetValue("Bogus content to be replaced"); text->GTKSetPangoMarkup(R"(Welcome to wxWidgets 3.3!)"); @@ -1573,7 +1573,7 @@ TEST_CASE("wxTextCtrl::Get/SetRTFValue", "[wxTextCtrl][rtf]") { wxWindow* const parent = wxTheApp->GetTopWindow(); - std::unique_ptr text(new wxTextCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RICH2 | wxTE_MULTILINE)); + auto text = make_unique(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RICH2 | wxTE_MULTILINE); text->SetRTFValue(R"({\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}} {\colortbl ;\red192\green80\blue77;} @@ -1598,7 +1598,7 @@ TEST_CASE("wxTextCtrl::SearchText", "[wxTextCtrl][search]") { wxWindow* const parent = wxTheApp->GetTopWindow(); - std::unique_ptr text(new wxTextCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RICH2 | wxTE_MULTILINE)); + auto text = make_unique(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RICH2 | wxTE_MULTILINE); text->SetValue(R"(Allows more than 30Kb of text (on all Windows versions) @@ -1731,10 +1731,10 @@ TEST_CASE("wxTextCtrl::InitialCanUndo", "[wxTextCtrl][undo]") INFO("wxTextCtrl with style " << style); wxWindow* const parent = wxTheApp->GetTopWindow(); - std::unique_ptr text(new wxTextCtrl(parent, wxID_ANY, "", - wxDefaultPosition, - wxDefaultSize, - style)); + auto text = make_unique(parent, wxID_ANY, "", + wxDefaultPosition, + wxDefaultSize, + style); CHECK( !text->CanUndo() ); } @@ -1754,11 +1754,11 @@ TEST_CASE("wxTextCtrl::EmptyUndoBuffer", "[wxTextCtrl][undo]") return; } - std::unique_ptr text(new wxTextCtrl(wxTheApp->GetTopWindow(), - wxID_ANY, "", - wxDefaultPosition, - wxDefaultSize, - wxTE_MULTILINE | wxTE_RICH2)); + auto text = make_unique(wxTheApp->GetTopWindow(), + wxID_ANY, "", + wxDefaultPosition, + wxDefaultSize, + wxTE_MULTILINE | wxTE_RICH2); text->AppendText("foo"); diff --git a/tests/controls/windowtest.cpp b/tests/controls/windowtest.cpp index 3e52956058..bdb5b5c126 100644 --- a/tests/controls/windowtest.cpp +++ b/tests/controls/windowtest.cpp @@ -197,8 +197,7 @@ static void DoTestShowHideEvent(wxWindow* window) TEST_CASE_METHOD(WindowTestCase, "Window::ScrolledWindowPhysicalScrolling", "[window][scroll]") { - std::unique_ptr - win(new ScrollCountingWindow(wxTheApp->GetTopWindow())); + auto win = make_unique(wxTheApp->GetTopWindow()); win->EnableScrolling(false, false); win->Scroll(1, 2); @@ -623,8 +622,8 @@ TEST_CASE_METHOD(WindowTestCase, "Window::FindWindowBy", "[window]") TEST_CASE_METHOD(WindowTestCase, "Window::SizerErrors", "[window][sizer][error]") { wxWindow* const child = new wxWindow(m_window, wxID_ANY); - std::unique_ptr const sizer1(new wxBoxSizer(wxHORIZONTAL)); - std::unique_ptr const sizer2(new wxBoxSizer(wxHORIZONTAL)); + auto const sizer1 = make_unique(wxHORIZONTAL); + auto const sizer2 = make_unique(wxHORIZONTAL); REQUIRE_NOTHROW( sizer1->Add(child) ); #ifdef __WXDEBUG__ diff --git a/tests/docview/updateallviews.cpp b/tests/docview/updateallviews.cpp index 81f65db546..030976f13f 100644 --- a/tests/docview/updateallviews.cpp +++ b/tests/docview/updateallviews.cpp @@ -120,7 +120,7 @@ void MyView::OnUpdate(wxView* WXUNUSED(sender), wxObject* hint /*= nullptr*/) TEST_CASE("wxDocument::UpdateAllViews", "[docview]") { - const std::unique_ptr doc(new MyDocument()); + const auto doc = make_unique(); wxView* view50 = nullptr; for (int i = 0; i < 100; ++i) { diff --git a/tests/events/enterleave.cpp b/tests/events/enterleave.cpp index c06819f120..1cec1e1a1b 100644 --- a/tests/events/enterleave.cpp +++ b/tests/events/enterleave.cpp @@ -41,8 +41,7 @@ TEST_CASE("EnterLeaveEvents", "[wxEvent][enter-leave]") return; } - std::unique_ptr - panel(new wxPanel(wxTheApp->GetTopWindow(), wxID_ANY)); + auto panel = make_unique(wxTheApp->GetTopWindow(), wxID_ANY); auto button = new wxButton(panel.get(), wxID_ANY, "button", {50, 50}); auto textctrl = new wxTextCtrl(panel.get(), wxID_ANY, "", {160, 50}); diff --git a/tests/filesys/filesystest.cpp b/tests/filesys/filesystest.cpp index b9c3cfece9..9e5486968e 100644 --- a/tests/filesys/filesystest.cpp +++ b/tests/filesys/filesystest.cpp @@ -364,7 +364,7 @@ TEST_CASE("wxFileSystem::ArchiveDuplicateNames", "[filesys][fs_arc][zip][find]") } const size_t zipLen = mos.GetSize(); - std::unique_ptr zipData(new unsigned char[zipLen]); + auto zipData = make_unique(zipLen); mos.CopyTo(zipData.get(), zipLen); wxMemoryFSHandler::AddFile("dup.zip", zipData.get(), zipLen); diff --git a/tests/graphics/clipper.cpp b/tests/graphics/clipper.cpp index e7de427b57..23bf3c2621 100644 --- a/tests/graphics/clipper.cpp +++ b/tests/graphics/clipper.cpp @@ -676,9 +676,9 @@ TEST_CASE("ClipperTestCase::wxPaintDC", "[clipper][dc][paintdc]") #if defined(__WXGTK__) // Under wxGTK we need to have two children (at least) because if there // is one child its paint area is set to fill the whole parent frame. - std::unique_ptr w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); + auto w0 = make_unique(wxTheApp->GetTopWindow(), wxID_ANY); #endif // wxGTK - std::unique_ptr win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0))); + auto win = make_unique(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0)); win->SetClientSize(s_dcSize); // Wait for the first paint event to be sure diff --git a/tests/graphics/clippingbox.cpp b/tests/graphics/clippingbox.cpp index dca889b60c..0a24020fab 100644 --- a/tests/graphics/clippingbox.cpp +++ b/tests/graphics/clippingbox.cpp @@ -3981,9 +3981,9 @@ TEST_CASE("ClippingBoxTestCase::wxPaintDC", "[clip][dc][paintdc]") #if defined(__WXGTK__) // Under wxGTK we need to have two children (at least) because if there // is one child its paint area is set to fill the whole parent frame. - std::unique_ptr w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); + auto w0 = make_unique(wxTheApp->GetTopWindow(), wxID_ANY); #endif // wxGTK - std::unique_ptr win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0))); + auto win = make_unique(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0)); win->SetClientSize(s_dcSize); // Wait for the first paint event to be sure diff --git a/tests/html/htmlparser.cpp b/tests/html/htmlparser.cpp index 534d1f1fca..58c7226371 100644 --- a/tests/html/htmlparser.cpp +++ b/tests/html/htmlparser.cpp @@ -263,7 +263,7 @@ TEST_CASE("wxHtmlCell::Detach", "[html][cell]") { wxMemoryDC dc; - std::unique_ptr const top(new wxHtmlContainerCell(nullptr)); + auto const top = make_unique(nullptr); wxHtmlContainerCell* const cont = new wxHtmlContainerCell(nullptr); wxHtmlCell* const cell1 = new wxHtmlWordCell("Hello", dc); wxHtmlCell* const cell2 = new wxHtmlColourCell(*wxRED); diff --git a/tests/misc/guifuncs.cpp b/tests/misc/guifuncs.cpp index 5224a607ff..f378106181 100644 --- a/tests/misc/guifuncs.cpp +++ b/tests/misc/guifuncs.cpp @@ -193,10 +193,10 @@ TEST_CASE("GUI::ClientToScreen", "[guifuncs]") tlw->Update(); wxYield(); - std::unique_ptr const - p1(new wxPanel(tlw, wxID_ANY, wxPoint(0, 0), wxSize(100, 50))); - std::unique_ptr const - p2(new wxPanel(tlw, wxID_ANY, wxPoint(0, 50), wxSize(100, 50))); + auto const p1 = make_unique(tlw, wxID_ANY, wxPoint(0, 0), + wxSize(100, 50)); + auto const p2 = make_unique(tlw, wxID_ANY, wxPoint(0, 50), + wxSize(100, 50)); wxWindow* const b = new wxWindow(p2.get(), wxID_ANY, wxPoint(10, 10), wxSize(30, 10)); @@ -257,8 +257,8 @@ TEST_CASE("GUI::FindWindowAtPoint", "[guifuncs]") // assertion messages. parent->SetLabel("parent"); - std::unique_ptr btn1(new TestButton(parent, "1", wxPoint(10, 10))); - std::unique_ptr btn2(new TestButton(parent, "2", wxPoint(10, 90))); + auto btn1 = make_unique(parent, "1", wxPoint(10, 10)); + auto btn2 = make_unique(parent, "2", wxPoint(10, 90)); // No need to use std::unique_ptr<> for this one, it will be deleted by btn2. wxWindow* btn3 = new TestButton(btn2.get(), "3", wxPoint(20, 20)); @@ -296,8 +296,8 @@ TEST_CASE("wxWindow::Dump", "[window]") { CHECK_NOTHROW( wxDumpWindow(nullptr) ); - std::unique_ptr - button(new wxButton(wxTheApp->GetTopWindow(), wxID_ANY, "bloordyblop")); + auto button = make_unique(wxTheApp->GetTopWindow(), wxID_ANY, + "bloordyblop"); const std::string s = wxDumpWindow(button.get()).utf8_string(); diff --git a/tests/net/webrequest.cpp b/tests/net/webrequest.cpp index e9dc64c672..3fb67da9b2 100644 --- a/tests/net/webrequest.cpp +++ b/tests/net/webrequest.cpp @@ -692,7 +692,7 @@ TEST_CASE_METHOD(RequestFixture, return; Create("put"); - std::unique_ptr is(new wxFileInputStream("horse.png")); + auto is = make_unique("horse.png"); REQUIRE( is->IsOk() ); request.SetData(is.release(), "image/png"); @@ -1210,7 +1210,7 @@ TEST_CASE_METHOD(SyncRequestFixture, return; Create("put"); - std::unique_ptr is(new wxFileInputStream("horse.png")); + auto is = make_unique("horse.png"); REQUIRE( is->IsOk() ); request.SetData(is.release(), "image/png"); diff --git a/tests/sizers/boxsizer.cpp b/tests/sizers/boxsizer.cpp index 7e46306879..f0e2c4c88d 100644 --- a/tests/sizers/boxsizer.cpp +++ b/tests/sizers/boxsizer.cpp @@ -363,7 +363,7 @@ TEST_CASE_METHOD(BoxSizerTestCase, "BoxSizer::IncompatibleFlags", "[sizer]") #define ASSERT_SIZER_INVALID_FLAGS(f, msg) \ WX_ASSERT_FAILS_WITH_ASSERT_MESSAGE( \ "Expected assertion not generated for " msg, \ - std::unique_ptr item(new wxSizerItem(10, 10, 0, f)); \ + auto item = make_unique(10, 10, 0, f); \ sizer->Add(item.get()); \ item.release() \ ) diff --git a/tests/sizers/wrapsizer.cpp b/tests/sizers/wrapsizer.cpp index 2cb74eb5b3..2252f4399b 100644 --- a/tests/sizers/wrapsizer.cpp +++ b/tests/sizers/wrapsizer.cpp @@ -25,7 +25,7 @@ TEST_CASE("wxWrapSizer::CalcMin", "[wxWrapSizer]") { - std::unique_ptr win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); + auto win = make_unique(wxTheApp->GetTopWindow(), wxID_ANY); win->SetClientSize(180, 240); wxSizer *sizer = new wxWrapSizer(wxHORIZONTAL); @@ -87,7 +87,7 @@ TEST_CASE("wxWrapSizer::CalcMin", "[wxWrapSizer]") TEST_CASE("wxWrapSizer::CalcMinFromMinor", "[wxWrapSizer]") { - std::unique_ptr win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); + auto win = make_unique(wxTheApp->GetTopWindow(), wxID_ANY); win->SetClientSize(180, 240); wxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL); diff --git a/tests/streams/largefile.cpp b/tests/streams/largefile.cpp index d023e563c4..4290324d8e 100644 --- a/tests/streams/largefile.cpp +++ b/tests/streams/largefile.cpp @@ -224,7 +224,7 @@ protected: wxInputStream *LargeFileTest_wxFile::MakeInStream(const wxString& name) const { - std::unique_ptr in(new wxFileInputStream(name)); + auto in = make_unique(name); CHECK(in->IsOk()); return in.release(); } @@ -256,7 +256,7 @@ protected: wxInputStream *LargeFileTest_wxFFile::MakeInStream(const wxString& name) const { - std::unique_ptr in(new wxFFileInputStream(name)); + auto in = make_unique(name); CHECK(in->IsOk()); return in.release(); } diff --git a/tests/thread/misc.cpp b/tests/thread/misc.cpp index a06d0c4ab0..aa2f3fbf05 100644 --- a/tests/thread/misc.cpp +++ b/tests/thread/misc.cpp @@ -251,7 +251,7 @@ TEST_CASE("MiscThread::Semaphore", "[thread]") for ( int i = 0; i < 3*SEM_LIMIT; i++ ) { - std::unique_ptr t{new MySemaphoreThread(i, &sem)}; + auto t = make_unique(i, &sem); CHECK( t->Run() == wxTHREAD_NO_ERROR ); threads.push_back(std::move(t)); diff --git a/tests/thread/queue.cpp b/tests/thread/queue.cpp index 0f8a2972e6..34ffda4b53 100644 --- a/tests/thread/queue.cpp +++ b/tests/thread/queue.cpp @@ -82,8 +82,8 @@ TEST_CASE("wxMessageQueue::Receive", "[msgqueue]") for ( i = 0; i < threadCount; ++i ) { MyThread *previousThread = i == 0 ? nullptr : threads[i-1].get(); - std::unique_ptr - thread(new MyThread(WaitInfinitlyLong, previousThread, msgCount)); + auto thread = make_unique(WaitInfinitlyLong, previousThread, + msgCount); CHECK( thread->Create() == wxTHREAD_NO_ERROR ); threads.push_back(std::move(thread)); @@ -118,8 +118,8 @@ TEST_CASE("wxMessageQueue::Receive", "[msgqueue]") // should return wxMSGQUEUUE_TIMEOUT. TEST_CASE("wxMessageQueue::ReceiveTimeout", "[msgqueue]") { - std::unique_ptr thread1(new MyThread(WaitWithTimeout, nullptr, 2)); - std::unique_ptr thread2(new MyThread(WaitWithTimeout, nullptr, 2)); + auto thread1 = make_unique(WaitWithTimeout, nullptr, 2); + auto thread2 = make_unique(WaitWithTimeout, nullptr, 2); CHECK( thread1->Create() == wxTHREAD_NO_ERROR ); CHECK( thread2->Create() == wxTHREAD_NO_ERROR ); diff --git a/tests/validators/valnum.cpp b/tests/validators/valnum.cpp index 11c7ad3e30..47abab681a 100644 --- a/tests/validators/valnum.cpp +++ b/tests/validators/valnum.cpp @@ -245,9 +245,9 @@ TEST_CASE_METHOD(NumValidatorTestCase, "ValNum::ZeroAsBlank", "[valnum]") m_text->SetSize(100, 50); m_text->MarkDirty(); m_text->SetFocus(); - std::unique_ptr - text2(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "Test", - wxPoint(0, 100), wxSize(100, 50))); + auto text2 = make_unique(wxTheApp->GetTopWindow(), wxID_ANY, + "Test", wxPoint(0, 100), + wxSize(100, 50)); text2->SetFocus(); WaitFor("the other control to become focused", [&text2]() { return text2->HasFocus(); diff --git a/tests/window/clientsize.cpp b/tests/window/clientsize.cpp index f1da3a59be..c784387771 100644 --- a/tests/window/clientsize.cpp +++ b/tests/window/clientsize.cpp @@ -49,9 +49,9 @@ TEST_CASE("wxWindow::ClientWindowSizeRoundTrip", "[window][client-size]") TEST_CASE("wxWindow::MinClientSize", "[window][client-size]") { - std::unique_ptr w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY, - wxDefaultPosition, wxDefaultSize, - wxBORDER_THEME)); + auto w = make_unique(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxDefaultSize, + wxBORDER_THEME); w->SetSize(wxSize(1,1)); const wxSize szw = w->GetClientSize(); CHECK(szw.GetWidth() >= 0); @@ -64,9 +64,9 @@ TEST_CASE("wxWindow::SetClientSize", "[window][client-size]") // Under wxGTK we need to have two children (at least) because if there // is exactly one child its size is set to fill the whole parent frame // and the window cannot be resized - see wxTopLevelWindowBase::Layout(). - std::unique_ptr w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); + auto w0 = make_unique(wxTheApp->GetTopWindow(), wxID_ANY); #endif // wxGTK - std::unique_ptr w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); + auto w = make_unique(wxTheApp->GetTopWindow(), wxID_ANY); wxRect reqSize = wxTheApp->GetTopWindow()->GetClientRect(); reqSize.Deflate(25); @@ -96,14 +96,13 @@ TEST_CASE("wxScrolled::ClientSize", "[window][client-size][scroll]") // This window is not used for anything, but it must exist to prevent the // test frame from resizing the panel created below to fill it entirely, // which is what would happen if the panel were its unique child. - std::unique_ptr const - sibling(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY)); + auto const sibling = + make_unique(wxTheApp->GetTopWindow(), wxID_ANY); // The scrolled window must be really laid out by its parent for the // scrollbars to appear, so use a sizer in a panel of our own instead of // just creating it as a child of the test frame. - std::unique_ptr const - parent(new wxPanel(wxTheApp->GetTopWindow())); + auto const parent = make_unique(wxTheApp->GetTopWindow()); // Make the panel big enough for the scrollbars to fit inside it. parent->SetSize(wxSize(200, 200)); diff --git a/tests/window/setsize.cpp b/tests/window/setsize.cpp index e89516fa05..58c46a7dab 100644 --- a/tests/window/setsize.cpp +++ b/tests/window/setsize.cpp @@ -52,7 +52,7 @@ protected: TEST_CASE("wxWindow::SetSize", "[window][size]") { - std::unique_ptr w(new MyWindow(wxTheApp->GetTopWindow())); + auto w = make_unique(wxTheApp->GetTopWindow()); SECTION("Simple") { @@ -73,7 +73,7 @@ TEST_CASE("wxWindow::SetSize", "[window][size]") TEST_CASE("wxWindow::GetBestSize", "[window][size][best-size]") { - std::unique_ptr w(new MyWindow(wxTheApp->GetTopWindow())); + auto w = make_unique(wxTheApp->GetTopWindow()); CHECK( wxSize(50, 250) == w->GetBestSize() ); @@ -86,8 +86,8 @@ TEST_CASE("wxWindow::GetBestSize", "[window][size][best-size]") TEST_CASE("wxWindow::MovePreservesSize", "[window][size][move]") { - std::unique_ptr - w(new wxFrame(wxTheApp->GetTopWindow(), wxID_ANY, "Test child frame")); + auto w = make_unique(wxTheApp->GetTopWindow(), wxID_ANY, + "Test child frame"); // Unfortunately showing the window is asynchronous, at least when using // X11, so we have to wait for some time before retrieving its true diff --git a/tests/xml/xmltest.cpp b/tests/xml/xmltest.cpp index 1de960ad41..00109894c7 100644 --- a/tests/xml/xmltest.cpp +++ b/tests/xml/xmltest.cpp @@ -66,7 +66,7 @@ void CheckXml(const wxXmlNode *n, ...) TEST_CASE("Xml::InsertChild", "[xml]") { - std::unique_ptr root(new wxXmlNode(wxXML_ELEMENT_NODE, "root")); + auto root = make_unique(wxXML_ELEMENT_NODE, "root"); root->AddChild(new wxXmlNode(wxXML_ELEMENT_NODE, "1")); wxXmlNode *two = new wxXmlNode(wxXML_ELEMENT_NODE, "2"); root->AddChild(two); @@ -86,7 +86,7 @@ TEST_CASE("Xml::InsertChild", "[xml]") TEST_CASE("Xml::InsertChildAfter", "[xml]") { - std::unique_ptr root(new wxXmlNode(wxXML_ELEMENT_NODE, "root")); + auto root = make_unique(wxXML_ELEMENT_NODE, "root"); root->InsertChildAfter(new wxXmlNode(wxXML_ELEMENT_NODE, "1"), nullptr); CheckXml(root.get(), "1", nullptr); diff --git a/tests/xml/xrctest.cpp b/tests/xml/xrctest.cpp index 8d6ecab668..e66b0f1005 100644 --- a/tests/xml/xrctest.cpp +++ b/tests/xml/xrctest.cpp @@ -45,7 +45,7 @@ static const char *TEST_XRC_FILE = "test.xrc"; void LoadXrcFrom(const wxString& xrcText) { wxStringInputStream sis(xrcText); - std::unique_ptr xmlDoc(new wxXmlDocument(sis)); + auto xmlDoc = make_unique(sis); REQUIRE( xmlDoc->IsOk() ); // Load the xrc we've just created