Пример #1
0
void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
    typedef std::dynarray<T> dynA;
    
    dynA d1 ( vals, alloc );
    assert ( d1.size () == vals.size() );
    assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
    check_allocator ( d1, alloc );
    }
Пример #2
0
DEF_TEST(GrAllocator, reporter) {

    // Test combinations of allocators with and without stack storage and with different block
    // sizes.
    SkTArray<GrTAllocator<C>*> allocators;
    GrTAllocator<C> a1(1);
    allocators.push_back(&a1);
    GrTAllocator<C> a2(2);
    allocators.push_back(&a2);
    GrTAllocator<C> a5(5);
    allocators.push_back(&a5);

    GrSTAllocator<1, C> sa1;
    allocators.push_back(&a1);
    GrSTAllocator<3, C> sa3;
    allocators.push_back(&sa3);
    GrSTAllocator<4, C> sa4;
    allocators.push_back(&sa4);

    for (int i = 0; i < allocators.count(); ++i) {
        check_allocator(allocators[i], 0, 0, reporter);
        check_allocator(allocators[i], 1, 1, reporter);
        check_allocator(allocators[i], 2, 2, reporter);
        check_allocator(allocators[i], 10, 1, reporter);
        check_allocator(allocators[i], 10, 5, reporter);
        check_allocator(allocators[i], 10, 10, reporter);
        check_allocator(allocators[i], 100, 10, reporter);
    }
}
Пример #3
0
void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
    typedef std::dynarray<T> dynA;
    
    dynA d1 ( 4, alloc1 );
    assert ( d1.size () == 4 );
    assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
    check_allocator ( d1, alloc1 );

    dynA d2 ( 7, val, alloc1 );
    assert ( d2.size () == 7 );
    assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } ));
    check_allocator ( d2, alloc1 );

    dynA d3 ( d2, alloc2 );
    assert ( d3.size () == 7 );
    assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));   
    check_allocator ( d3, alloc2 );
    }