diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/generic/array_ref_ut.pyx | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/generic/array_ref_ut.pyx')
-rw-r--r-- | util/generic/array_ref_ut.pyx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/util/generic/array_ref_ut.pyx b/util/generic/array_ref_ut.pyx new file mode 100644 index 0000000000..67b69a365c --- /dev/null +++ b/util/generic/array_ref_ut.pyx @@ -0,0 +1,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)
\ No newline at end of file |