blob: 67b69a365c9ce53f4632e225e924f4da5def8723 (
plain) (
blame)
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
|
import pytest
import unittest
from util.generic.array_ref cimport TArrayRef
from util.generic.vector cimport TVector
class TestArrayRef(unittest.TestCase):
def test_array_data_reference(self):
array_size = 30
cdef TVector[int] vec
for i in xrange(array_size):
vec.push_back(i)
cdef TArrayRef[int] array_ref = TArrayRef[int](vec.data(), vec.size())
for i in xrange(array_size / 2):
array_ref[array_size - 1 - i] = array_ref[i]
for i in xrange(array_size):
self.assertEqual(array_ref[i], array_size - 1 - i)
def test_array_vec_reference(self):
array_size = 30
cdef TVector[int] vec
for i in xrange(array_size):
vec.push_back(i)
cdef TArrayRef[int] array_ref = TArrayRef[int](vec)
for i in xrange(array_size / 2):
array_ref[array_size - 1 - i] = array_ref[i]
for i in xrange(array_size):
self.assertEqual(array_ref[i], array_size - 1 - i)
|