git-svn-id: svn://db.shs.com.ru/pip@858 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
34 lines
848 B
C++
34 lines
848 B
C++
//
|
|
// Created by fomenko on 24.09.2019.
|
|
//
|
|
|
|
#include "gtest/gtest.h"
|
|
#include "executor.h"
|
|
#include "pimutex.h"
|
|
|
|
const int WAIT_THREAD_TIME_MS = 30;
|
|
|
|
TEST(ExcutorIntegrationTest, execute_is_runnable_invoke) {
|
|
PIMutex m;
|
|
int invokedRunnables = 0;
|
|
PIThreadPoolExecutor executorService(1);
|
|
executorService.execute([&]() {
|
|
m.lock();
|
|
invokedRunnables++;
|
|
m.unlock();
|
|
});
|
|
piMSleep(WAIT_THREAD_TIME_MS);
|
|
ASSERT_EQ(invokedRunnables, 1);
|
|
}
|
|
|
|
TEST(ExcutorIntegrationTest, execute_is_not_execute_after_shutdown) {
|
|
bool isRunnableInvoke = false;
|
|
PIThreadPoolExecutor executorService(1);
|
|
executorService.shutdown();
|
|
executorService.execute([&]() {
|
|
isRunnableInvoke = true;
|
|
});
|
|
piMSleep(WAIT_THREAD_TIME_MS);
|
|
ASSERT_FALSE(isRunnableInvoke);
|
|
}
|