/* * queuetest.cpp * * Created on: 07.11.2012 * Author: trifon */ #include "test.h" #include "squeue.cpp" #include "lqueue.cpp" typedef LQueue<> TestQueue; bool emptyTest() { TestQueue q; return q.empty(); } bool emptyErrorTest() { TestQueue q; q.push(42); return !q.empty(); } bool pushPopTest() { TestQueue q; for(int i = 0; i < 10; i++) q.push(i); for(int i = 0; i < 10; i++) { int j; if (!q.pop(j) || j != i) return false; } return true; } bool copyTest() { TestQueue q1; q1.push(10); q1.push(15); TestQueue q2 = q1; int x; q1.pop(x); // x == 10 q1.push(20); q2.push(30); q1.pop(x); // x == 15 return q1.head(x) && x == 20; } const int TEST_NUMBER = 4; Test tests[] = { { "emptyTest", emptyTest }, { "emptyErrorTest", emptyErrorTest }, { "pushPopTest", pushPopTest }, { "copyTest", copyTest }, }; int main() { runTests(tests, TEST_NUMBER); }