7332ed1e8f
And modify it a bit to match my recent work. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
69 lines
1.6 KiB
C++
69 lines
1.6 KiB
C++
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <queue.h>
|
|
#include "test.h"
|
|
|
|
|
|
class TestQueue : public Queue
|
|
{
|
|
public:
|
|
TestQueue() : Queue() {}
|
|
TestQueue(unsigned int f) : Queue(f) {}
|
|
unsigned int get_cur() { return _cur; }
|
|
unsigned int get_flags() { return _flags; }
|
|
unsigned int get_length() { return _length; }
|
|
std::list <sort_info> get_sorder() { return _sort_order; };
|
|
};
|
|
|
|
|
|
void test_default()
|
|
{
|
|
TestQueue q;
|
|
|
|
test :: equal(q.get_cur(), (unsigned)-1);
|
|
test :: equal(q.get_flags(), (unsigned)0);
|
|
test :: equal(q.get_length(), (unsigned)0);
|
|
test :: equal(q.get_sorder().size(), (size_t)0);
|
|
test :: equal(q.next(), (Track *)NULL);
|
|
}
|
|
|
|
void test_constructor(unsigned int flags)
|
|
{
|
|
TestQueue q(flags | (1 << 30));
|
|
|
|
test :: equal(q.get_cur(), (unsigned)-1);
|
|
test :: equal(q.get_flags(), flags);
|
|
test :: equal(q.get_length(), (unsigned)0);
|
|
test :: equal(q.get_sorder().size(), (size_t)0);
|
|
test :: equal(q.next(), (Track *)NULL);
|
|
}
|
|
|
|
void test_flags()
|
|
{
|
|
TestQueue q(0);
|
|
|
|
test :: equal(q.get_flags(), (unsigned)0);
|
|
|
|
q.set_flag(Q_ENABLED);
|
|
test :: equal(q.get_flags(), (unsigned)Q_ENABLED);
|
|
|
|
q.unset_flag(Q_ENABLED);
|
|
test :: equal(q.get_flags(), (unsigned)0);
|
|
|
|
q.set_flag(Q_REPEAT);
|
|
q.set_flag(Q_RANDOM);
|
|
test :: equal(q.has_flag(Q_ENABLED), false);
|
|
test :: equal(q.has_flag(Q_RANDOM), true);
|
|
test :: equal(q.has_flag(Q_REPEAT), true);
|
|
test :: equal(q.has_flag(Q_NO_SORT), false);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
run_test("Queue Default Constructor Test", test_default);
|
|
run_test("Queue Constructor Test", test_constructor, Q_ENABLED | Q_RANDOM);
|
|
run_test("Queue Flag Test", test_flags);
|
|
return 0;
|
|
}
|