Use make_unique<>() instead of "new" in the tests

No real changes, just avoid explicit "new" calls.
This commit is contained in:
Vadim Zeitlin
2026-09-04 15:24:34 +02:00
parent 5daf1beb9c
commit c8003a0a06
28 changed files with 125 additions and 129 deletions
+1 -1
View File
@@ -514,7 +514,7 @@ TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::Layout", "[aui]")
TEST_CASE("wxAuiToolBar::Items", "[aui][toolbar]")
{
std::unique_ptr<wxAuiToolBar> tbar{new wxAuiToolBar(wxTheApp->GetTopWindow())};
auto tbar = make_unique<wxAuiToolBar>(wxTheApp->GetTopWindow());
// Check that adding more toolbar elements doesn't invalidate the existing
// pointers.
+1 -1
View File
@@ -2783,7 +2783,7 @@ TEST_CASE("GridBlockCoords::SymDifference", "[grid]")
TEST_CASE("wxGrid::Events", "[grid][event]")
{
const std::unique_ptr<wxGrid> grid(new wxGrid());
const auto grid = make_unique<wxGrid>();
EventCounter selectEvents(grid.get(), wxEVT_GRID_SELECT_CELL);
+2 -2
View File
@@ -24,8 +24,8 @@
TEST_CASE("wxInfoBar::Buttons", "[wxInfoBar]")
{
const std::unique_ptr<wxInfoBar>
info(new wxInfoBar(wxTheApp->GetTopWindow(), wxID_ANY, wxINFOBAR_CHECKBOX));
const auto info = make_unique<wxInfoBar>(wxTheApp->GetTopWindow(), wxID_ANY,
wxINFOBAR_CHECKBOX);
CHECK(info->GetButtonCount() == 0);
+14 -12
View File
@@ -92,38 +92,40 @@ TEST_CASE("wxControl::Label", "[wxControl][label]")
{
SECTION("wxStaticText")
{
const std::unique_ptr<wxStaticText>
st(new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
const auto st = make_unique<wxStaticText>(wxTheApp->GetTopWindow(),
wxID_ANY, ORIGINAL_LABEL);
DoTestLabel(st.get());
}
SECTION("wxStaticText/ellipsized")
{
const std::unique_ptr<wxStaticText>
st(new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL,
wxDefaultPosition, wxDefaultSize,
wxST_ELLIPSIZE_START));
const auto st = make_unique<wxStaticText>(wxTheApp->GetTopWindow(),
wxID_ANY, ORIGINAL_LABEL,
wxDefaultPosition,
wxDefaultSize,
wxST_ELLIPSIZE_START);
DoTestLabel(st.get());
}
SECTION("wxGenericStaticText")
{
const std::unique_ptr<wxGenericStaticText>
gst(new wxGenericStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
const auto gst =
make_unique<wxGenericStaticText>(wxTheApp->GetTopWindow(),
wxID_ANY, ORIGINAL_LABEL);
DoTestLabel(gst.get());
}
SECTION("wxCheckBox")
{
const std::unique_ptr<wxCheckBox>
cb(new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
const auto cb = make_unique<wxCheckBox>(wxTheApp->GetTopWindow(),
wxID_ANY, ORIGINAL_LABEL);
DoTestLabel(cb.get());
}
SECTION("wxTextCtrl")
{
const std::unique_ptr<wxTextCtrl>
tc(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
const auto tc = make_unique<wxTextCtrl>(wxTheApp->GetTopWindow(),
wxID_ANY, ORIGINAL_LABEL);
// Setting the label of a wxTextCtrl should _not_ work, it has value
// and not a label.
+1 -1
View File
@@ -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<wxWindow> win0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
auto win0 = make_unique<wxWindow>(wxTheApp->GetTopWindow(), wxID_ANY);
#endif // wxGTK
std::unique_ptr<wxPropertyGridManager> pgManager(CreateGrid(-1, -1));
+5 -5
View File
@@ -196,11 +196,11 @@ TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::SetString", "[radiobox]")
TEST_CASE("RadioBox::NoItems", "[radiobox]")
{
std::unique_ptr<wxRadioBox>
radio(new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "Empty",
wxDefaultPosition, wxDefaultSize,
0, nullptr,
1, wxRA_SPECIFY_COLS));
auto radio = make_unique<wxRadioBox>(wxTheApp->GetTopWindow(), wxID_ANY,
"Empty",
wxDefaultPosition, wxDefaultSize,
0, nullptr,
1, wxRA_SPECIFY_COLS);
CHECK( radio->GetCount() == 0 );
CHECK( radio->IsEmpty() );
+23 -23
View File
@@ -89,22 +89,22 @@ TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Group", "[radiobutton]")
wxWindow* const parent = wxTheApp->GetTopWindow();
// Create two different radio groups.
std::unique_ptr<wxRadioButton> g1radio0(new wxRadioButton(parent, wxID_ANY, "radio 1.0",
wxDefaultPosition, wxDefaultSize,
wxRB_GROUP));
auto g1radio0 = make_unique<wxRadioButton>(parent, wxID_ANY, "radio 1.0",
wxDefaultPosition, wxDefaultSize,
wxRB_GROUP);
std::unique_ptr<wxRadioButton> g1radio1(new wxRadioButton(parent, wxID_ANY, "radio 1.1"));
auto g1radio1 = make_unique<wxRadioButton>(parent, wxID_ANY, "radio 1.1");
std::unique_ptr<wxRadioButton> g2radio0(new wxRadioButton(parent, wxID_ANY, "radio 2.0",
wxDefaultPosition, wxDefaultSize,
wxRB_GROUP));
auto g2radio0 = make_unique<wxRadioButton>(parent, wxID_ANY, "radio 2.0",
wxDefaultPosition, wxDefaultSize,
wxRB_GROUP);
std::unique_ptr<wxRadioButton> g2radio1(new wxRadioButton(parent, wxID_ANY, "radio 2.1"));
auto g2radio1 = make_unique<wxRadioButton>(parent, wxID_ANY, "radio 2.1");
// Check that having another control between radio buttons doesn't break
// grouping.
std::unique_ptr<wxStaticText> text(new wxStaticText(parent, wxID_ANY, "Label"));
std::unique_ptr<wxRadioButton> g2radio2(new wxRadioButton(parent, wxID_ANY, "radio 2.2"));
auto text = make_unique<wxStaticText>(parent, wxID_ANY, "Label");
auto g2radio2 = make_unique<wxRadioButton>(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<wxRadioButton> gradio0(new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton",
wxDefaultPosition,
wxDefaultSize, wxRB_GROUP));
auto gradio0 = make_unique<wxRadioButton>(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton",
wxDefaultPosition,
wxDefaultSize, wxRB_GROUP);
std::unique_ptr<wxRadioButton> gradio1(new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton"));
auto gradio1 = make_unique<wxRadioButton>(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton");
gradio1->SetValue(true);
//Create a "single" button (by default it will not be selected)
std::unique_ptr<wxRadioButton> sradio(new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton",
wxDefaultPosition,
wxDefaultSize, wxRB_SINGLE));
auto sradio = make_unique<wxRadioButton>(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton",
wxDefaultPosition,
wxDefaultSize, wxRB_SINGLE);
//Create a non-grouped button and select it
std::unique_ptr<wxRadioButton> ngradio(new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton"));
auto ngradio = make_unique<wxRadioButton>(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<wxPanel> parentPanel(new wxPanel(tlw));
auto parentPanel = make_unique<wxPanel>(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
+9 -12
View File
@@ -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<wxSpinCtrlDouble> spin(new wxSpinCtrlDouble);
auto spin = make_unique<wxSpinCtrlDouble>();
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<wxSpinCtrlDouble> sc(new wxSpinCtrlDouble
(
wxTheApp->GetTopWindow(),
wxID_ANY,
wxEmptyString,
wxDefaultPosition,
wxDefaultSize,
wxSP_ARROW_KEYS,
0, 50, 0,
inc
));
auto sc = make_unique<wxSpinCtrlDouble>(wxTheApp->GetTopWindow(),
wxID_ANY,
wxEmptyString,
wxDefaultPosition,
wxDefaultSize,
wxSP_ARROW_KEYS,
0, 50, 0,
inc);
return sc->GetDigits();
}
+20 -20
View File
@@ -1420,10 +1420,10 @@ TEST_CASE("wxTextCtrl::GetBestSize", "[wxTextCtrl][best-size]")
{
wxSize operator()(const wxString& text) const
{
std::unique_ptr<wxTextCtrl>
t(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, text,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE));
auto t = make_unique<wxTextCtrl>(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<wxTextCtrl>
text(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, wxString(),
wxDefaultPosition, wxDefaultSize, style));
auto text = make_unique<wxTextCtrl>(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<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, "Hello"));
auto text = make_unique<wxTextCtrl>(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<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE));
auto text = make_unique<wxTextCtrl>(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
text->SetValue("Bogus content to be replaced");
text->GTKSetPangoMarkup(R"(Welcome to <span background="#D3D3D3" strikethrough="true">wxWidgets</span> 3.3!)");
@@ -1573,7 +1573,7 @@ TEST_CASE("wxTextCtrl::Get/SetRTFValue", "[wxTextCtrl][rtf]")
{
wxWindow* const parent = wxTheApp->GetTopWindow();
std::unique_ptr<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RICH2 | wxTE_MULTILINE));
auto text = make_unique<wxTextCtrl>(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<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RICH2 | wxTE_MULTILINE));
auto text = make_unique<wxTextCtrl>(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<wxTextCtrl> text(new wxTextCtrl(parent, wxID_ANY, "",
wxDefaultPosition,
wxDefaultSize,
style));
auto text = make_unique<wxTextCtrl>(parent, wxID_ANY, "",
wxDefaultPosition,
wxDefaultSize,
style);
CHECK( !text->CanUndo() );
}
@@ -1754,11 +1754,11 @@ TEST_CASE("wxTextCtrl::EmptyUndoBuffer", "[wxTextCtrl][undo]")
return;
}
std::unique_ptr<wxTextCtrl> text(new wxTextCtrl(wxTheApp->GetTopWindow(),
wxID_ANY, "",
wxDefaultPosition,
wxDefaultSize,
wxTE_MULTILINE | wxTE_RICH2));
auto text = make_unique<wxTextCtrl>(wxTheApp->GetTopWindow(),
wxID_ANY, "",
wxDefaultPosition,
wxDefaultSize,
wxTE_MULTILINE | wxTE_RICH2);
text->AppendText("foo");
+3 -4
View File
@@ -197,8 +197,7 @@ static void DoTestShowHideEvent(wxWindow* window)
TEST_CASE_METHOD(WindowTestCase, "Window::ScrolledWindowPhysicalScrolling",
"[window][scroll]")
{
std::unique_ptr<ScrollCountingWindow>
win(new ScrollCountingWindow(wxTheApp->GetTopWindow()));
auto win = make_unique<ScrollCountingWindow>(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<wxSizer> const sizer1(new wxBoxSizer(wxHORIZONTAL));
std::unique_ptr<wxSizer> const sizer2(new wxBoxSizer(wxHORIZONTAL));
auto const sizer1 = make_unique<wxBoxSizer>(wxHORIZONTAL);
auto const sizer2 = make_unique<wxBoxSizer>(wxHORIZONTAL);
REQUIRE_NOTHROW( sizer1->Add(child) );
#ifdef __WXDEBUG__
+1 -1
View File
@@ -120,7 +120,7 @@ void MyView::OnUpdate(wxView* WXUNUSED(sender), wxObject* hint /*= nullptr*/)
TEST_CASE("wxDocument::UpdateAllViews", "[docview]")
{
const std::unique_ptr<wxDocument> doc(new MyDocument());
const auto doc = make_unique<MyDocument>();
wxView* view50 = nullptr;
for (int i = 0; i < 100; ++i)
{
+1 -2
View File
@@ -41,8 +41,7 @@ TEST_CASE("EnterLeaveEvents", "[wxEvent][enter-leave]")
return;
}
std::unique_ptr<wxPanel>
panel(new wxPanel(wxTheApp->GetTopWindow(), wxID_ANY));
auto panel = make_unique<wxPanel>(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});
+1 -1
View File
@@ -364,7 +364,7 @@ TEST_CASE("wxFileSystem::ArchiveDuplicateNames", "[filesys][fs_arc][zip][find]")
}
const size_t zipLen = mos.GetSize();
std::unique_ptr<unsigned char[]> zipData(new unsigned char[zipLen]);
auto zipData = make_unique<unsigned char[]>(zipLen);
mos.CopyTo(zipData.get(), zipLen);
wxMemoryFSHandler::AddFile("dup.zip", zipData.get(), zipLen);
+2 -2
View File
@@ -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<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
auto w0 = make_unique<wxWindow>(wxTheApp->GetTopWindow(), wxID_ANY);
#endif // wxGTK
std::unique_ptr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0)));
auto win = make_unique<wxWindow>(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0));
win->SetClientSize(s_dcSize);
// Wait for the first paint event to be sure
+2 -2
View File
@@ -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<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
auto w0 = make_unique<wxWindow>(wxTheApp->GetTopWindow(), wxID_ANY);
#endif // wxGTK
std::unique_ptr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0)));
auto win = make_unique<wxWindow>(wxTheApp->GetTopWindow(), wxID_ANY, wxPoint(0, 0));
win->SetClientSize(s_dcSize);
// Wait for the first paint event to be sure
+1 -1
View File
@@ -263,7 +263,7 @@ TEST_CASE("wxHtmlCell::Detach", "[html][cell]")
{
wxMemoryDC dc;
std::unique_ptr<wxHtmlContainerCell> const top(new wxHtmlContainerCell(nullptr));
auto const top = make_unique<wxHtmlContainerCell>(nullptr);
wxHtmlContainerCell* const cont = new wxHtmlContainerCell(nullptr);
wxHtmlCell* const cell1 = new wxHtmlWordCell("Hello", dc);
wxHtmlCell* const cell2 = new wxHtmlColourCell(*wxRED);
+8 -8
View File
@@ -193,10 +193,10 @@ TEST_CASE("GUI::ClientToScreen", "[guifuncs]")
tlw->Update();
wxYield();
std::unique_ptr<wxPanel> const
p1(new wxPanel(tlw, wxID_ANY, wxPoint(0, 0), wxSize(100, 50)));
std::unique_ptr<wxPanel> const
p2(new wxPanel(tlw, wxID_ANY, wxPoint(0, 50), wxSize(100, 50)));
auto const p1 = make_unique<wxPanel>(tlw, wxID_ANY, wxPoint(0, 0),
wxSize(100, 50));
auto const p2 = make_unique<wxPanel>(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<wxWindow> btn1(new TestButton(parent, "1", wxPoint(10, 10)));
std::unique_ptr<wxWindow> btn2(new TestButton(parent, "2", wxPoint(10, 90)));
auto btn1 = make_unique<TestButton>(parent, "1", wxPoint(10, 10));
auto btn2 = make_unique<TestButton>(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<wxButton>
button(new wxButton(wxTheApp->GetTopWindow(), wxID_ANY, "bloordyblop"));
auto button = make_unique<wxButton>(wxTheApp->GetTopWindow(), wxID_ANY,
"bloordyblop");
const std::string s = wxDumpWindow(button.get()).utf8_string();
+2 -2
View File
@@ -692,7 +692,7 @@ TEST_CASE_METHOD(RequestFixture,
return;
Create("put");
std::unique_ptr<wxInputStream> is(new wxFileInputStream("horse.png"));
auto is = make_unique<wxFileInputStream>("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<wxInputStream> is(new wxFileInputStream("horse.png"));
auto is = make_unique<wxFileInputStream>("horse.png");
REQUIRE( is->IsOk() );
request.SetData(is.release(), "image/png");
+1 -1
View File
@@ -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<wxSizerItem> item(new wxSizerItem(10, 10, 0, f)); \
auto item = make_unique<wxSizerItem>(10, 10, 0, f); \
sizer->Add(item.get()); \
item.release() \
)
+2 -2
View File
@@ -25,7 +25,7 @@
TEST_CASE("wxWrapSizer::CalcMin", "[wxWrapSizer]")
{
std::unique_ptr<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
auto win = make_unique<wxWindow>(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<wxWindow> win(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
auto win = make_unique<wxWindow>(wxTheApp->GetTopWindow(), wxID_ANY);
win->SetClientSize(180, 240);
wxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
+2 -2
View File
@@ -224,7 +224,7 @@ protected:
wxInputStream *LargeFileTest_wxFile::MakeInStream(const wxString& name) const
{
std::unique_ptr<wxFileInputStream> in(new wxFileInputStream(name));
auto in = make_unique<wxFileInputStream>(name);
CHECK(in->IsOk());
return in.release();
}
@@ -256,7 +256,7 @@ protected:
wxInputStream *LargeFileTest_wxFFile::MakeInStream(const wxString& name) const
{
std::unique_ptr<wxFFileInputStream> in(new wxFFileInputStream(name));
auto in = make_unique<wxFFileInputStream>(name);
CHECK(in->IsOk());
return in.release();
}
+1 -1
View File
@@ -251,7 +251,7 @@ TEST_CASE("MiscThread::Semaphore", "[thread]")
for ( int i = 0; i < 3*SEM_LIMIT; i++ )
{
std::unique_ptr<MySemaphoreThread> t{new MySemaphoreThread(i, &sem)};
auto t = make_unique<MySemaphoreThread>(i, &sem);
CHECK( t->Run() == wxTHREAD_NO_ERROR );
threads.push_back(std::move(t));
+4 -4
View File
@@ -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<MyThread>
thread(new MyThread(WaitInfinitlyLong, previousThread, msgCount));
auto thread = make_unique<MyThread>(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<MyThread> thread1(new MyThread(WaitWithTimeout, nullptr, 2));
std::unique_ptr<MyThread> thread2(new MyThread(WaitWithTimeout, nullptr, 2));
auto thread1 = make_unique<MyThread>(WaitWithTimeout, nullptr, 2);
auto thread2 = make_unique<MyThread>(WaitWithTimeout, nullptr, 2);
CHECK( thread1->Create() == wxTHREAD_NO_ERROR );
CHECK( thread2->Create() == wxTHREAD_NO_ERROR );
+3 -3
View File
@@ -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<wxTextCtrl>
text2(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "Test",
wxPoint(0, 100), wxSize(100, 50)));
auto text2 = make_unique<wxTextCtrl>(wxTheApp->GetTopWindow(), wxID_ANY,
"Test", wxPoint(0, 100),
wxSize(100, 50));
text2->SetFocus();
WaitFor("the other control to become focused", [&text2]() {
return text2->HasFocus();
+8 -9
View File
@@ -49,9 +49,9 @@ TEST_CASE("wxWindow::ClientWindowSizeRoundTrip", "[window][client-size]")
TEST_CASE("wxWindow::MinClientSize", "[window][client-size]")
{
std::unique_ptr<wxWindow> w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY,
wxDefaultPosition, wxDefaultSize,
wxBORDER_THEME));
auto w = make_unique<wxWindow>(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<wxWindow> w0(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
auto w0 = make_unique<wxWindow>(wxTheApp->GetTopWindow(), wxID_ANY);
#endif // wxGTK
std::unique_ptr<wxWindow> w(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
auto w = make_unique<wxWindow>(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<wxWindow> const
sibling(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY));
auto const sibling =
make_unique<wxWindow>(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<wxWindow> const
parent(new wxPanel(wxTheApp->GetTopWindow()));
auto const parent = make_unique<wxPanel>(wxTheApp->GetTopWindow());
// Make the panel big enough for the scrollbars to fit inside it.
parent->SetSize(wxSize(200, 200));
+4 -4
View File
@@ -52,7 +52,7 @@ protected:
TEST_CASE("wxWindow::SetSize", "[window][size]")
{
std::unique_ptr<wxWindow> w(new MyWindow(wxTheApp->GetTopWindow()));
auto w = make_unique<MyWindow>(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<wxWindow> w(new MyWindow(wxTheApp->GetTopWindow()));
auto w = make_unique<MyWindow>(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<wxWindow>
w(new wxFrame(wxTheApp->GetTopWindow(), wxID_ANY, "Test child frame"));
auto w = make_unique<wxFrame>(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
+2 -2
View File
@@ -66,7 +66,7 @@ void CheckXml(const wxXmlNode *n, ...)
TEST_CASE("Xml::InsertChild", "[xml]")
{
std::unique_ptr<wxXmlNode> root(new wxXmlNode(wxXML_ELEMENT_NODE, "root"));
auto root = make_unique<wxXmlNode>(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<wxXmlNode> root(new wxXmlNode(wxXML_ELEMENT_NODE, "root"));
auto root = make_unique<wxXmlNode>(wxXML_ELEMENT_NODE, "root");
root->InsertChildAfter(new wxXmlNode(wxXML_ELEMENT_NODE, "1"), nullptr);
CheckXml(root.get(), "1", nullptr);
+1 -1
View File
@@ -45,7 +45,7 @@ static const char *TEST_XRC_FILE = "test.xrc";
void LoadXrcFrom(const wxString& xrcText)
{
wxStringInputStream sis(xrcText);
std::unique_ptr<wxXmlDocument> xmlDoc(new wxXmlDocument(sis));
auto xmlDoc = make_unique<wxXmlDocument>(sis);
REQUIRE( xmlDoc->IsOk() );
// Load the xrc we've just created