idle: Clean up unit test
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
afd47ce667
commit
1dfe475ade
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue