Esempio n. 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);
    }
}
Esempio n. 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);
    }
}
Esempio n. 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);
        }
    }
Esempio n. 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();
        }
    }
}
Esempio n. 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);
        }
    }
Esempio n. 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);
    }

}
Esempio n. 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);
}
Esempio n. 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);
    }
}
Esempio n. 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);
    }
}
Esempio n. 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());
    }
}
Esempio n. 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
}
Esempio n. 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);
    }
}
Esempio n. 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);
    }
}
Esempio n. 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
}
Esempio n. 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);
    }
}
Esempio n. 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());
    }
}