/* * queue_test.cpp * * Created on: 29.10.2013 * Author: trifon */ #include "test.h" #include "squeue.cpp" #include "lqueue.cpp" typedef LQueue TestQueue; bool emptyTest() { return TestQueue().empty(); } bool emptyPushTest() { TestQueue q; q.push(1); return !q.empty(); } bool errorPopHeadTest() { TestQueue q; int x; return !q.pop(x) && !q.head(x); } bool pushPopTest() { TestQueue q; for(int i = 1; i <= 10; i++) q.push(i); int x; for(int i = 1; i <= 10; i++) if (!q.pop(x) || x != i) return false; return true; } bool stressTest() { TestQueue q; int x; for(int i = 1; i <= 1000; i++) { if (!q.push(i) || !q.pop(x) || i != x) return false; } return q.empty(); } bool copyTest() { TestQueue q1; q1.push(1); TestQueue q2 = q1; int x; q1.pop(x); q1.push(2); return q2.pop(x) && x == 1; } int const NTESTS = 6; Test tests[] = { { "emptyTest", emptyTest }, { "emptyPushTest", emptyPushTest }, { "errorPopHeadTest", errorPopHeadTest }, { "pushPopTest", pushPopTest }, { "stressTest", stressTest }, { "copyTest", copyTest }, }; int main() { runTests(tests, NTESTS); return 0; }