diff --git a/CMakeLists.txt b/CMakeLists.txt index ac7915bb..28b51150 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,9 @@ include_directories(../external/googletest/googletest/include src/ tests) set(GTEST_SOURCE_FILES tests/scheduler_test_system.cpp tests/test_ensembles.cpp - tests/fixed_google_tests.cpp + tests/fixed_google_tests_v2.cpp src/scheduler.cpp + tests/test_log.cpp #tests/file_google_tests.cpp #tests/overlap_google_tests.cpp tests/scheduler_test_flog.cpp diff --git a/tests/fixed_google_tests_v2.cpp b/tests/fixed_google_tests_v2.cpp index 854953f1..76714e20 100644 --- a/tests/fixed_google_tests_v2.cpp +++ b/tests/fixed_google_tests_v2.cpp @@ -91,8 +91,11 @@ class SchedulerTest : public ::testing::Test /*returns array of task size to be inputed to scheduler*/ DeploymentSchedule_ * get_table(int size){ + if(size>deployment_table.size()){ + return nullptr; + } DeploymentSchedule_ deploy[size]; - std::copy(deployment_table.begin(), deployment_table.end(), deploy); + std::copy(deployment_table.begin(), deployment_table.begin() + size, deploy); return deploy; } @@ -115,13 +118,20 @@ class SchedulerTest : public ::testing::Test /*compares the test log with the expected values, as set in the test case*/ void compare(std::vector expected, int iterations){ for(int i=0; i expected){ - Scheduler s=get_table(num_tasks); + DeploymentSchedule_ * table=get_table(num_tasks); + if(table==nullptr){ + return; + } + Scheduler s(table); u_int32_t nextTaskTime=0; DeploymentSchedule_ ** nextTask; @@ -157,7 +167,9 @@ class SchedulerTest : public ::testing::Test TEST_F(SchedulerTest, TestDefault) { - + std::vector expected={ + {"A", 0}, {"B", 25}, {"C", 50}, {"A", 75}, {"B", 100}, {"C", 125}, + }; diff --git a/tests/test_log.cpp b/tests/test_log.cpp index 1b7ae9b7..5894fd74 100644 --- a/tests/test_log.cpp +++ b/tests/test_log.cpp @@ -14,6 +14,15 @@ } + string Log:: getName(){ + return taskName; + } + u_int32_t Log :: getRunTime(){ + return runTime; + + } + + bool operator== (const Log& a, const Log& b){ return ((a.taskName==b.taskName)&& (a.runTime==b.runTime)); } \ No newline at end of file diff --git a/tests/test_log.hpp b/tests/test_log.hpp index ff4f7f00..5e3bf09b 100644 --- a/tests/test_log.hpp +++ b/tests/test_log.hpp @@ -10,6 +10,9 @@ class Log{ friend bool operator== (const Log& a, const Log& b); + string getName(); + u_int32_t getRunTime(); + private: string taskName; u_int32_t runTime;