예제 #1
0
void pri_queue_test_equality(void)
{
    for (int i = 0; i != test_size; ++i)
    {
        pri_queue q, r;
        test_data data = make_test_data(i);
        fill_q(q, data);
        std::reverse(data.begin(), data.end());
        fill_q(r, data);

        BOOST_REQUIRE(r == q);
    }
}
예제 #2
0
void pri_queue_test_inequality(void)
{
    for (int i = 1; i != test_size; ++i)
    {
        pri_queue q, r;
        test_data data = make_test_data(i);
        fill_q(q, data);
        data[0] = data.back() + 1;
        fill_q(r, data);

        BOOST_REQUIRE(r != q);
    }
}
예제 #3
0
    static void run(void)
    {
        for (int i = 0; i != test_size; ++i) {
            pri_queue q, r;
            GENERATE_TEST_DATA(i);

            fill_q(q, data_q);
            fill_q(r, data_r);

            q.merge(r);

            BOOST_REQUIRE(r.empty());
            check_q(q, data);
        }
    }
예제 #4
0
void pri_queue_test_ordered_iterators(void)
{
    for (int i = 0; i != test_size; ++i) {
        test_data data = make_test_data(i);
        test_data shuffled (data);
        std::random_shuffle(shuffled.begin(), shuffled.end());
        pri_queue q;
        BOOST_REQUIRE(q.ordered_begin() == q.ordered_end());
        fill_q(q, shuffled);

        test_data data_from_queue(q.ordered_begin(), q.ordered_end());
        std::reverse(data_from_queue.begin(), data_from_queue.end());
        BOOST_REQUIRE(data == data_from_queue);

        for (unsigned long i = 0; i != data.size(); ++i)
            BOOST_REQUIRE(std::find(q.ordered_begin(), q.ordered_end(), data[i]) != q.ordered_end());

        for (unsigned long i = 0; i != data.size(); ++i)
            BOOST_REQUIRE(std::find(q.ordered_begin(), q.ordered_end(), data[i] + data.size()) == q.ordered_end());

        for (unsigned long i = 0; i != data.size(); ++i) {
            BOOST_REQUIRE_EQUAL((long)std::distance(q.begin(), q.end()), (long)(data.size() - i));
            q.pop();
        }
    }
}
예제 #5
0
    static void run (void)
    {
        for (int i = 0; i != test_size; ++i) {
            pri_queue1 q;
            pri_queue2 r;
            GENERATE_TEST_DATA(i);

            fill_q(q, data_q);
            fill_q(r, data_r);

            boost::heap::heap_merge(q, r);

            BOOST_REQUIRE(r.empty());
            check_q(q, data);
        }
    }
예제 #6
0
void pri_queue_test_less(void)
{
    for (int i = 1; i != test_size; ++i)
    {
        pri_queue q, r;
        test_data data = make_test_data(i);
        test_data r_data(data);
        r_data.pop_back();

        fill_q(q, data);
        fill_q(r, r_data);

        BOOST_REQUIRE(r < q);
    }

    for (int i = 1; i != test_size; ++i)
    {
        pri_queue q, r;
        test_data data = make_test_data(i);
        test_data r_data(data);
        data.push_back(data.back() + 1);

        fill_q(q, data);
        fill_q(r, r_data);

        BOOST_REQUIRE(r < q);
    }

    for (int i = 1; i != test_size; ++i)
    {
        pri_queue q, r;
        test_data data = make_test_data(i);
        test_data r_data(data);

        data.back() += 1;

        fill_q(q, data);
        fill_q(r, r_data);

        BOOST_REQUIRE(r < q);
    }

    for (int i = 1; i != test_size; ++i)
    {
        pri_queue q, r;
        test_data data = make_test_data(i);
        test_data r_data(data);

        r_data.front() -= 1;

        fill_q(q, data);
        fill_q(r, r_data);

        BOOST_REQUIRE(r < q);
    }

}
예제 #7
0
void run_reserve_heap_tests(void)
{
    test_data data = make_test_data(test_size);
    pri_queue q;
    q.reserve(6);
    fill_q(q, data);

    check_q(q, data);
}
예제 #8
0
void pri_queue_test_sequential_push(void)
{
    for (int i = 0; i != test_size; ++i)
    {
        pri_queue q;
        test_data data = make_test_data(i);
        fill_q(q, data);
        check_q(q, data);
    }
}
예제 #9
0
void pri_queue_test_sequential_reverse_push(void)
{
    for (int i = 0; i != test_size; ++i)
    {
        pri_queue q;
        test_data data = make_test_data(i);
        std::reverse(data.begin(), data.end());
        fill_q(q, data);
        std::reverse(data.begin(), data.end());
        check_q(q, data);
    }
}
예제 #10
0
void pri_queue_test_clear(void)
{
    for (int i = 0; i != test_size; ++i)
    {
        pri_queue q;
        test_data data = make_test_data(i);
        fill_q(q, data);

        q.clear();
        BOOST_REQUIRE(q.size() == 0);
        BOOST_REQUIRE(q.empty());
    }
}
예제 #11
0
void pri_queue_test_moveconstructor(void)
{
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
    pri_queue q;
    test_data data = make_test_data(test_size);
    fill_q(q, data);

    pri_queue r(std::move(q));

    check_q(r, data);
    BOOST_REQUIRE(q.empty());
#endif
}
예제 #12
0
void pri_queue_test_copyconstructor(void)
{
    for (int i = 0; i != test_size; ++i)
    {
        pri_queue q;
        test_data data = make_test_data(i);
        fill_q(q, data);

        pri_queue r(q);

        check_q(r, data);
    }
}
예제 #13
0
void pri_queue_test_assignment(void)
{
    for (int i = 0; i != test_size; ++i)
    {
        pri_queue q;
        test_data data = make_test_data(i);
        fill_q(q, data);

        pri_queue r;
        r = q;

        check_q(r, data);
    }
}
예제 #14
0
void pri_queue_test_move_assignment(void)
{
#ifdef BOOST_HAS_RVALUE_REFS
    pri_queue q;
    test_data data = make_test_data(test_size);
    fill_q(q, data);

    pri_queue r;
    r = std::move(q);

    check_q(r, data);
    BOOST_REQUIRE(q.empty());
#endif
}
예제 #15
0
void pri_queue_test_random_push(void)
{
    for (int i = 0; i != test_size; ++i)
    {
        pri_queue q;
        test_data data = make_test_data(i);

        test_data shuffled (data);
        std::random_shuffle(shuffled.begin(), shuffled.end());

        fill_q(q, shuffled);

        check_q(q, data);
    }
}
예제 #16
0
void pri_queue_test_swap(void)
{
    for (int i = 0; i != test_size; ++i)
    {
        pri_queue q;
        test_data data = make_test_data(i);
        test_data shuffled (data);
        std::random_shuffle(shuffled.begin(), shuffled.end());
        fill_q(q, shuffled);

        pri_queue r;

        q.swap(r);
        check_q(r, data);
        BOOST_REQUIRE(q.empty());
    }
}