Stop using macro-based array in wxThread unit test
Use vector of unique_ptr instead.
This commit is contained in:
parent
b3ff1f3e61
commit
8b2e010841
1 changed files with 10 additions and 8 deletions
|
|
@ -19,6 +19,9 @@
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// globals
|
// globals
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
@ -194,8 +197,6 @@ private:
|
||||||
int m_i;
|
int m_i;
|
||||||
};
|
};
|
||||||
|
|
||||||
WX_DEFINE_ARRAY_PTR(wxThread *, ArrayThreads);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// test class
|
// test class
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
@ -277,18 +278,19 @@ void MiscThreadTestCase::TestSemaphore()
|
||||||
static const int SEM_LIMIT = 3;
|
static const int SEM_LIMIT = 3;
|
||||||
|
|
||||||
wxSemaphore sem(SEM_LIMIT, SEM_LIMIT);
|
wxSemaphore sem(SEM_LIMIT, SEM_LIMIT);
|
||||||
ArrayThreads threads;
|
std::vector<std::unique_ptr<MySemaphoreThread>> threads;
|
||||||
|
|
||||||
for ( int i = 0; i < 3*SEM_LIMIT; i++ )
|
for ( int i = 0; i < 3*SEM_LIMIT; i++ )
|
||||||
{
|
{
|
||||||
threads.Add(new MySemaphoreThread(i, &sem));
|
std::unique_ptr<MySemaphoreThread> t{new MySemaphoreThread(i, &sem)};
|
||||||
CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, threads.Last()->Run() );
|
CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, t->Run() );
|
||||||
|
|
||||||
|
threads.push_back(std::move(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( size_t n = 0; n < threads.GetCount(); n++ )
|
for ( auto& t : threads )
|
||||||
{
|
{
|
||||||
CPPUNIT_ASSERT_EQUAL( 0, (wxUIntPtr)threads[n]->Wait() );
|
CPPUNIT_ASSERT_EQUAL( 0, (wxUIntPtr)t->Wait() );
|
||||||
delete threads[n];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue