From 1dfe475ade4bad18240f90f4fe6676105fc0326d Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 6 Jan 2015 08:31:41 -0500 Subject: [PATCH] idle: Clean up unit test Signed-off-by: Anna Schumaker --- tests/core/idle.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/core/idle.cpp b/tests/core/idle.cpp index 489660ef..2281a5f9 100644 --- a/tests/core/idle.cpp +++ b/tests/core/idle.cpp @@ -8,6 +8,7 @@ #include +static float N = 0; static float cur = -1; static void inc_cur(float &expected) @@ -16,19 +17,19 @@ static void inc_cur(float &expected) check_equal(cur, expected); } -static void test_idle_queue(float n) +static void test_idle_queue() { test_equal(idle :: get_progress(), (float)1.0); test_equal(idle :: run_task(), false); - for (float i = 0; i < n; i++) + for (float i = 0; i < N; i++) idle :: schedule(inc_cur, i); test_equal(idle :: get_progress(), (float)0.0); test :: begin(); - for (float i = 0; i < (n - 1); i++) { + for (float i = 0; i < (N - 1); i++) { check_equal(idle :: run_task(), true); - check_equal(idle :: get_progress(), (i + 1) / n); + check_equal(idle :: get_progress(), (i + 1) / N); } test :: success(); @@ -36,14 +37,15 @@ static void test_idle_queue(float n) test_equal(idle :: get_progress(), (float)1.0); } -static void do_test(float n) +static void do_test(unsigned int n) { std::stringstream ss; ss << " (n = " << n << ")"; const std::string n_str = ss.str(); + N = n; cur = -1; - run_test("Idle Queue Test" + n_str, test_idle_queue, n); + run_test("Idle Queue Test" + n_str, test_idle_queue); } int main(int argc, char **argv)