// provided by xzj #include #include #include #include #include "priority_queue.hpp" long long aa=13131,bb=5353,MOD=1e9+7,now=1; int rand() { for(int i=1;i<3;i++) now=(now * aa + bb) % MOD; return now; } class T1//no_construct { public: int data; T1(int key):data(key){} }; bool operator == (const T1 &a,const T1 &b) { return a.data == b.data; } std::ostream &operator <<(std::ostream &os, const T1 &a){ os< void test() { sjtu::priority_queue q; int test_num=10000; for(int i=1;i<=test_num;i++) { q.push(T(rand())); if(i % 100==0) { std::cout< 900) q.pop(); } } template void copy_test() { sjtu::priority_queue q; int num=5000; for(int i=1;i<=num;i++) q.push(T(rand())); for(int j=1;j<=5;j++) { sjtu::priority_queue t(q); for(int i=1;i<=100;i++) t.push(T(rand())); for(int k=1;k<=10;k++) { std::cout< p; p=t; p=p=p=p; for(int i=1;i<=100;i++) p.push(T(rand())); for(int k=1;k<=10;k++) { std::cout<(); test(); test(); } void advanced_test() { printf("Advanced test..."); test(); test(); } void normal_copy_test() { printf("Normal copy&= test..."); copy_test(); copy_test(); copy_test(); } void advanced_copy_test() { printf("Advanced copy&= test..."); copy_test(); copy_test(); } void exception_test() { bool flag = 0; printf("Exception test..."); sjtu::priority_queue q; for(int i=1;i<=100;i++) q.push(rand()); for(int i=1;i<=100;i++) q.pop(); try{ q.pop(); } catch(sjtu::container_is_empty) {flag = 1;} catch(...){flag = 0;} if(!flag) { puts("Wrong Answer(pop)"); return; } try{ int tmp(q.top()); } catch(sjtu::container_is_empty) {flag = 1;} catch(...){flag = 0;} if(!flag) { puts("Wrong Answer(top)"); return; } puts("Accept"); } int main(int argc, char *const argv[]) { //freopen("testans-priority_queue-advance","w",stdout); puts("Test Start"); normal_test(); normal_copy_test(); advanced_test(); advanced_copy_test(); exception_test(); return 0; }