File size: 565 Bytes
be11144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <unittest/unittest.h>
#include <thrust/distance.h>

// TODO expand this with other iterator types (forward, bidirectional, etc.)

template <typename Vector>
void TestDistance(void)
{
    typedef typename Vector::iterator Iterator;

    Vector v(100);

    Iterator i = v.begin();

    ASSERT_EQUAL(thrust::distance(i, v.end()), 100);

    i++;

    ASSERT_EQUAL(thrust::distance(i, v.end()), 99);

    i += 49;

    ASSERT_EQUAL(thrust::distance(i, v.end()), 50);
    
    ASSERT_EQUAL(thrust::distance(i, i), 0);
}
DECLARE_VECTOR_UNITTEST(TestDistance);