Rewrite executor to template & come back executor unit tests

This commit is contained in:
5 changed files with 169 additions and 92 deletions

View File

@@ -1,8 +1,7 @@
#include "gtest/gtest.h"
#include "executor.h"
#include "pimutex.h"
const int WAIT_THREAD_TIME_MS = 30;
#include "testutil.h"
TEST(ExcutorIntegrationTest, execute_is_runnable_invoke) {
PIMutex m;
@@ -14,11 +13,13 @@ TEST(ExcutorIntegrationTest, execute_is_runnable_invoke) {
m.unlock();
});
piMSleep(WAIT_THREAD_TIME_MS);
m.lock();
ASSERT_EQ(invokedRunnables, 1);
m.unlock();
}
TEST(ExcutorIntegrationTest, execute_is_not_execute_after_shutdown) {
bool isRunnableInvoke = false;
volatile bool isRunnableInvoke = false;
PIThreadPoolExecutor executorService(1);
executorService.shutdown();
executorService.execute([&]() {
@@ -29,7 +30,7 @@ TEST(ExcutorIntegrationTest, execute_is_not_execute_after_shutdown) {
}
TEST(ExcutorIntegrationTest, execute_is_execute_before_shutdown) {
bool isRunnableInvoke = false;
volatile bool isRunnableInvoke = false;
PIThreadPoolExecutor executorService(1);
executorService.execute([&]() {
piMSleep(WAIT_THREAD_TIME_MS);