ocarina/tests/idle/idle.cpp

65 lines
1.3 KiB
C++

/*
* Copyright 2013 (c) Anna Schumaker.
*/
#include <idle.h>
#include <print.h>
#include <string>
struct TestStruct {
int i;
unsigned int u;
char c;
std::string s;
};
static void test_0(unsigned int &i)
{
print("Test 0: %u\n", i);
}
static void test_1(int &i)
{
print("Test 1: %d\n", i);
}
static void test_2(char &i)
{
print("Test 2: %c\n", i);
}
static void test_3(std::string &str)
{
print("Test 3: %s\n", str.c_str());
}
static void test_4(TestStruct &struc)
{
print("Test 4: %d %u %c %s\n", struc.i, struc.u, struc.c, struc.s.c_str());
}
static void test_5(TestStruct *&struc)
{
print("Test 5: %d %u %c %s\n", struc->i, struc->u, struc->c, struc->s.c_str());
}
int main(int argc, char **argv)
{
std::string string = "This is a string";
TestStruct struc1 = { -4, 4, 'd', "This is another string", };
TestStruct struc2 = { -5, 5, 'e', "This is yet another string", };
idle :: schedule(test_0, (unsigned int) 0);
idle :: schedule(test_1, 1);
idle :: schedule(test_2, 'b');
idle :: schedule(test_3, string);
idle :: schedule(test_4, struc1);
idle :: schedule(test_5, &struc2);
do {
print("Idle queue progress: %f\n", idle :: get_progress());
} while (idle :: run_task() == true);
print("Idle queue progress: %f\n", idle :: get_progress());
return 0;
}