mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 20:59:45 +01:00
Poco 1.9.1 assert true (#2255)
* Rename assert by assertTrue * Update submodules * Missing assertTrue * Rename poco_assertTrue to poco_assert * Rename poco_assertTrue to poco_assert
This commit is contained in:
committed by
Aleksandar Fabijanic
parent
5a1bf5eb4a
commit
960ecb38f0
@@ -159,15 +159,15 @@ void ThreadTest::testThread()
|
||||
{
|
||||
Thread thread;
|
||||
MyRunnable r;
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
thread.start(r);
|
||||
Thread::sleep(200);
|
||||
assert (thread.isRunning());
|
||||
assertTrue (thread.isRunning());
|
||||
r.notify();
|
||||
thread.join();
|
||||
assert (!thread.isRunning());
|
||||
assert (r.ran());
|
||||
assert (!r.threadName().empty());
|
||||
assertTrue (!thread.isRunning());
|
||||
assertTrue (r.ran());
|
||||
assertTrue (!r.threadName().empty());
|
||||
}
|
||||
|
||||
|
||||
@@ -178,8 +178,8 @@ void ThreadTest::testNamedThread()
|
||||
thread.start(r);
|
||||
r.notify();
|
||||
thread.join();
|
||||
assert (r.ran());
|
||||
assert (r.threadName() == "MyThread");
|
||||
assertTrue (r.ran());
|
||||
assertTrue (r.threadName() == "MyThread");
|
||||
}
|
||||
|
||||
|
||||
@@ -200,47 +200,47 @@ void ThreadTest::testThreads()
|
||||
MyRunnable r2;
|
||||
MyRunnable r3;
|
||||
MyRunnable r4;
|
||||
assert (!thread1.isRunning());
|
||||
assert (!thread2.isRunning());
|
||||
assert (!thread3.isRunning());
|
||||
assert (!thread4.isRunning());
|
||||
assertTrue (!thread1.isRunning());
|
||||
assertTrue (!thread2.isRunning());
|
||||
assertTrue (!thread3.isRunning());
|
||||
assertTrue (!thread4.isRunning());
|
||||
thread1.start(r1);
|
||||
Thread::sleep(200);
|
||||
assert (thread1.isRunning());
|
||||
assert (!thread2.isRunning());
|
||||
assert (!thread3.isRunning());
|
||||
assert (!thread4.isRunning());
|
||||
assertTrue (thread1.isRunning());
|
||||
assertTrue (!thread2.isRunning());
|
||||
assertTrue (!thread3.isRunning());
|
||||
assertTrue (!thread4.isRunning());
|
||||
thread2.start(r2);
|
||||
thread3.start(r3);
|
||||
thread4.start(r4);
|
||||
Thread::sleep(200);
|
||||
assert (thread1.isRunning());
|
||||
assert (thread2.isRunning());
|
||||
assert (thread3.isRunning());
|
||||
assert (thread4.isRunning());
|
||||
assertTrue (thread1.isRunning());
|
||||
assertTrue (thread2.isRunning());
|
||||
assertTrue (thread3.isRunning());
|
||||
assertTrue (thread4.isRunning());
|
||||
r4.notify();
|
||||
thread4.join();
|
||||
assert (!thread4.isRunning());
|
||||
assert (thread1.isRunning());
|
||||
assert (thread2.isRunning());
|
||||
assert (thread3.isRunning());
|
||||
assertTrue (!thread4.isRunning());
|
||||
assertTrue (thread1.isRunning());
|
||||
assertTrue (thread2.isRunning());
|
||||
assertTrue (thread3.isRunning());
|
||||
r3.notify();
|
||||
thread3.join();
|
||||
assert (!thread3.isRunning());
|
||||
assertTrue (!thread3.isRunning());
|
||||
r2.notify();
|
||||
thread2.join();
|
||||
assert (!thread2.isRunning());
|
||||
assertTrue (!thread2.isRunning());
|
||||
r1.notify();
|
||||
thread1.join();
|
||||
assert (!thread1.isRunning());
|
||||
assert (r1.ran());
|
||||
assert (r1.threadName() == "Thread1");
|
||||
assert (r2.ran());
|
||||
assert (r2.threadName() == "Thread2");
|
||||
assert (r3.ran());
|
||||
assert (r3.threadName() == "Thread3");
|
||||
assert (r4.ran());
|
||||
assert (r4.threadName() == "Thread4");
|
||||
assertTrue (!thread1.isRunning());
|
||||
assertTrue (r1.ran());
|
||||
assertTrue (r1.threadName() == "Thread1");
|
||||
assertTrue (r2.ran());
|
||||
assertTrue (r2.threadName() == "Thread2");
|
||||
assertTrue (r3.ran());
|
||||
assertTrue (r3.threadName() == "Thread3");
|
||||
assertTrue (r4.ran());
|
||||
assertTrue (r4.threadName() == "Thread4");
|
||||
}
|
||||
|
||||
|
||||
@@ -248,14 +248,14 @@ void ThreadTest::testJoin()
|
||||
{
|
||||
Thread thread;
|
||||
MyRunnable r;
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
thread.start(r);
|
||||
Thread::sleep(200);
|
||||
assert (thread.isRunning());
|
||||
assert (!thread.tryJoin(100));
|
||||
assertTrue (thread.isRunning());
|
||||
assertTrue (!thread.tryJoin(100));
|
||||
r.notify();
|
||||
assert (thread.tryJoin(500));
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (thread.tryJoin(500));
|
||||
assertTrue (!thread.isRunning());
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ void ThreadTest::testNotJoin()
|
||||
}
|
||||
|
||||
Thread::sleep(100);
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
}
|
||||
|
||||
|
||||
@@ -279,30 +279,30 @@ void ThreadTest::testTrySleep()
|
||||
{
|
||||
Thread thread;
|
||||
TrySleepRunnable r;
|
||||
assert(r.isSleepy());
|
||||
assert(!thread.isRunning());
|
||||
assert(r.counter() == 0);
|
||||
assertTrue (r.isSleepy());
|
||||
assertTrue (!thread.isRunning());
|
||||
assertTrue (r.counter() == 0);
|
||||
thread.start(r);
|
||||
assert(thread.isRunning());
|
||||
assert(r.counter() == 0);
|
||||
assert(r.isSleepy());
|
||||
assertTrue (thread.isRunning());
|
||||
assertTrue (r.counter() == 0);
|
||||
assertTrue (r.isSleepy());
|
||||
Thread::sleep(100);
|
||||
assert(r.counter() == 0);
|
||||
assert(r.isSleepy());
|
||||
assertTrue (r.counter() == 0);
|
||||
assertTrue (r.isSleepy());
|
||||
thread.wakeUp(); Thread::sleep(10);
|
||||
assert(r.counter() == 1);
|
||||
assert(r.isSleepy());
|
||||
assertTrue (r.counter() == 1);
|
||||
assertTrue (r.isSleepy());
|
||||
Thread::sleep(100);
|
||||
assert(r.counter() == 1);
|
||||
assertTrue (r.counter() == 1);
|
||||
thread.wakeUp(); Thread::sleep(10);
|
||||
assert(r.counter() == 2);
|
||||
assert(r.isSleepy());
|
||||
assertTrue (r.counter() == 2);
|
||||
assertTrue (r.isSleepy());
|
||||
Thread::sleep(200);
|
||||
assert(r.counter() == 3);
|
||||
assert(!r.isSleepy());
|
||||
assert(!thread.isRunning());
|
||||
assertTrue (r.counter() == 3);
|
||||
assertTrue (!r.isSleepy());
|
||||
assertTrue (!thread.isRunning());
|
||||
thread.wakeUp();
|
||||
assert(!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
}
|
||||
|
||||
|
||||
@@ -324,20 +324,20 @@ void ThreadTest::testThreadTarget()
|
||||
ThreadTarget te(&MyRunnable::staticFunc);
|
||||
Thread thread;
|
||||
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
|
||||
int tmp = MyRunnable::_staticVar;
|
||||
thread.start(te);
|
||||
thread.join();
|
||||
assert (tmp + 1 == MyRunnable::_staticVar);
|
||||
assertTrue (tmp + 1 == MyRunnable::_staticVar);
|
||||
|
||||
ThreadTarget te1(freeFunc);
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
|
||||
tmp = MyRunnable::_staticVar;
|
||||
thread.start(te1);
|
||||
thread.join();
|
||||
assert (tmp + 1 == MyRunnable::_staticVar);
|
||||
assertTrue (tmp + 1 == MyRunnable::_staticVar);
|
||||
}
|
||||
|
||||
|
||||
@@ -345,19 +345,19 @@ void ThreadTest::testThreadFunction()
|
||||
{
|
||||
Thread thread;
|
||||
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
|
||||
int tmp = MyRunnable::_staticVar;
|
||||
thread.start(freeFunc, &tmp);
|
||||
thread.join();
|
||||
assert (tmp * 2 == MyRunnable::_staticVar);
|
||||
assertTrue (tmp * 2 == MyRunnable::_staticVar);
|
||||
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
|
||||
tmp = MyRunnable::_staticVar = 0;
|
||||
thread.start(freeFunc, &tmp);
|
||||
thread.join();
|
||||
assert (0 == MyRunnable::_staticVar);
|
||||
assertTrue (0 == MyRunnable::_staticVar);
|
||||
}
|
||||
|
||||
|
||||
@@ -374,27 +374,27 @@ void ThreadTest::testThreadFunctor()
|
||||
{
|
||||
Thread thread;
|
||||
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
|
||||
MyRunnable::_staticVar = 0;
|
||||
thread.startFunc(Functor());
|
||||
thread.join();
|
||||
assert (1 == MyRunnable::_staticVar);
|
||||
assertTrue (1 == MyRunnable::_staticVar);
|
||||
|
||||
assert (!thread.isRunning());
|
||||
assertTrue (!thread.isRunning());
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
|
||||
Thread thread2;
|
||||
|
||||
assert (!thread2.isRunning());
|
||||
assertTrue (!thread2.isRunning());
|
||||
|
||||
MyRunnable::_staticVar = 0;
|
||||
thread.startFunc([] () {MyRunnable::_staticVar++;});
|
||||
thread.join();
|
||||
assert (1 == MyRunnable::_staticVar);
|
||||
assertTrue (1 == MyRunnable::_staticVar);
|
||||
|
||||
assert (!thread2.isRunning());
|
||||
assertTrue (!thread2.isRunning());
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -406,36 +406,36 @@ void ThreadTest::testThreadStackSize()
|
||||
|
||||
Thread thread;
|
||||
|
||||
assert (0 == thread.getStackSize());
|
||||
assertTrue (0 == thread.getStackSize());
|
||||
thread.setStackSize(stackSize);
|
||||
assert (stackSize <= thread.getStackSize());
|
||||
assertTrue (stackSize <= thread.getStackSize());
|
||||
int tmp = MyRunnable::_staticVar;
|
||||
thread.start(freeFunc, &tmp);
|
||||
thread.join();
|
||||
assert (tmp * 2 == MyRunnable::_staticVar);
|
||||
assertTrue (tmp * 2 == MyRunnable::_staticVar);
|
||||
|
||||
stackSize = 1;
|
||||
thread.setStackSize(stackSize);
|
||||
|
||||
#if !defined(POCO_OS_FAMILY_BSD) // on BSD family, stack size is rounded
|
||||
#ifdef PTHREAD_STACK_MIN
|
||||
assert (PTHREAD_STACK_MIN == thread.getStackSize());
|
||||
assertTrue (PTHREAD_STACK_MIN == thread.getStackSize());
|
||||
#else
|
||||
assert (stackSize >= thread.getStackSize());
|
||||
assertTrue (stackSize >= thread.getStackSize());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
tmp = MyRunnable::_staticVar;
|
||||
thread.start(freeFunc, &tmp);
|
||||
thread.join();
|
||||
assert (tmp * 2 == MyRunnable::_staticVar);
|
||||
assertTrue (tmp * 2 == MyRunnable::_staticVar);
|
||||
|
||||
thread.setStackSize(0);
|
||||
assert (0 == thread.getStackSize());
|
||||
assertTrue (0 == thread.getStackSize());
|
||||
tmp = MyRunnable::_staticVar;
|
||||
thread.start(freeFunc, &tmp);
|
||||
thread.join();
|
||||
assert (tmp * 2 == MyRunnable::_staticVar);
|
||||
assertTrue (tmp * 2 == MyRunnable::_staticVar);
|
||||
}
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@ void ThreadTest::testSleep()
|
||||
Poco::Timestamp start;
|
||||
Thread::sleep(200);
|
||||
Poco::Timespan elapsed = start.elapsed();
|
||||
assert (elapsed.totalMilliseconds() >= 190 && elapsed.totalMilliseconds() < 250);
|
||||
assertTrue (elapsed.totalMilliseconds() >= 190 && elapsed.totalMilliseconds() < 250);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user