#include #include #include #include #include "time.hpp" #include "template_helpers.hpp" // fake RuntimeID & AverageQueueLength wich is otherwise in "quant_types.hpp" template struct RuntimeID { static const uint8_t value = T::runtimeId; }; template struct AverageQueueSize { static const uint64_t value = T::aql; }; template struct Foo { Foo(int i) : val(i) {} int operator() () { return val; } int val; typedef T quant_t; }; struct A { static const unsigned char runtimeId = 0; static const uint64_t aql = 1000; static const char* const name; }; const char* const A::name = "A"; struct B { static const unsigned char runtimeId = 1; static const uint64_t aql = 2000; static const char* const name; }; const char* const B::name = "B"; struct C { static const unsigned char runtimeId = 2; static const uint64_t aql = 3000; static const char* const name; }; const char* const C::name = "C"; typedef boost::mpl::vector DiscreteQuantorList; // prevent quant_types to be included #define sKmf7ztuNbBT3ua3iNX4k5rtsg0 #include "multi_queue.hpp" #include "mempool.hpp" using namespace std; template void test(int line, int testid, T ex, T got) { if (ex != got) { cout << "line " << line << ", test " << testid << ", expected " << ex << ", got " << got << endl; exit(-1); } } int main() { using boost::make_tuple; typedef MultiQueue > mq_t; mq_t mq{}; Time ct(0); // macro helpers //#define PMQ {for(int i=0; i(ct,Time(v),10*v); PMQ } #define T(v,q,command) { \ test(__LINE__, 1, mq.minType(), RuntimeID::value); \ test(__LINE__, 2, mq.min(), Time(v)); \ test(__LINE__, 3, mq.get()(ct).minVal(), Time(v)); \ test(__LINE__, 4, mq.get()(ct).minPayload()(), 10*v); \ mq.command(ct); \ PMQ \ } #define Tg(v,q) T(v,q,removeMin) #define Tl(v,q) T(v,q,removeLocalMin) // test extractMin PMQ I(9,C); I(7,C); I(3,B); I(3,B); I(3,A); I(2,C); I(2,A); I(2,B); I(1,A); Tg(1,A); Tg(2,A); Tg(2,B); Tg(2,C); Tg(3,A); Tg(3,B); Tg(3,B); Tg(7,C); Tg(9,C); // test extractLocalMin PMQ I(9,C); I(7,C); I(3,B); I(3,B); I(3,A); I(2,C); I(2,A); I(2,B); I(1,A); Tl(1,A); Tl(2,A); Tl(2,B); Tl(2,C); Tl(3,A); Tl(3,B); Tl(3,B); Tl(7,C); Tl(9,C); // test extractLocalMin PMQ I(9,C); I(7,C); I(3,B); I(3,B); I(3,A); I(2,C); I(2,A); I(2,B); I(1,A); mq.removeLocalMin(ct); Tl(1,A); Tl(2,A); //Tl(2,B); mq.removeLocalMin(ct); Tl(2,C); // Tl(3,A); Tl(3,B); Tl(3,B); Tl(7,C); Tl(9,C); // got until here -> success return 0; }