diff options
author | Stanislav Kirillov <staskirillov@gmail.com> | 2022-02-10 16:46:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:07 +0300 |
commit | 92fe2b1e7bc79f7b95adef61714fc003f6ea4a1c (patch) | |
tree | 817034f4ca57c9f841bb047ec94630c2e78a2b1d /util/generic/hash_set_ut.pyx | |
parent | 53c76da6d9f6cc5a17f6029df396f0e3bc1ff47d (diff) | |
download | ydb-92fe2b1e7bc79f7b95adef61714fc003f6ea4a1c.tar.gz |
Restoring authorship annotation for Stanislav Kirillov <staskirillov@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/generic/hash_set_ut.pyx')
-rw-r--r-- | util/generic/hash_set_ut.pyx | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/util/generic/hash_set_ut.pyx b/util/generic/hash_set_ut.pyx index bdcf6284af..e2d3dfd5c7 100644 --- a/util/generic/hash_set_ut.pyx +++ b/util/generic/hash_set_ut.pyx @@ -1,53 +1,53 @@ -# cython: c_string_type=str, c_string_encoding=utf8 - -from util.generic.hash_set cimport THashSet -from util.generic.string cimport TString - -import pytest -import unittest - -from cython.operator cimport dereference as deref - - +# cython: c_string_type=str, c_string_encoding=utf8 + +from util.generic.hash_set cimport THashSet +from util.generic.string cimport TString + +import pytest +import unittest + +from cython.operator cimport dereference as deref + + class TestHashSet(unittest.TestCase): - - def test_simple_constructor_equality_operator(self): - cdef THashSet[int] c1 - c1.insert(1) - assert c1.size() == 1 - c1.insert(2) - c1.insert(2) - c1.insert(2) - c1.insert(2) - assert c1.size() == 2 - assert c1.contains(2) - assert not c1.contains(5) - cdef THashSet[int] c2 = c1 - assert c1 == c2 - c1.insert(3) - assert c1 != c2 - c1.erase(3) - assert c1 == c2 - - def test_insert_erase(self): - cdef THashSet[TString] tmp - self.assertTrue(tmp.insert("one").second) - self.assertFalse(tmp.insert("one").second) - self.assertTrue(tmp.insert("two").second) - cdef TString one = "one" - cdef TString two = "two" - self.assertEqual(tmp.erase(one), 1) - self.assertEqual(tmp.erase(two), 1) - self.assertEqual(tmp.size(), 0) - self.assertTrue(tmp.empty()) - - def test_iterators_and_find(self): - cdef THashSet[TString] tmp - self.assertTrue(tmp.begin() == tmp.end()) - self.assertTrue(tmp.find("1") == tmp.end()) - tmp.insert("1") - self.assertTrue(tmp.begin() != tmp.end()) - cdef THashSet[TString].iterator it = tmp.find("1") - self.assertTrue(it != tmp.end()) - self.assertEqual(deref(it), "1") - + + def test_simple_constructor_equality_operator(self): + cdef THashSet[int] c1 + c1.insert(1) + assert c1.size() == 1 + c1.insert(2) + c1.insert(2) + c1.insert(2) + c1.insert(2) + assert c1.size() == 2 + assert c1.contains(2) + assert not c1.contains(5) + cdef THashSet[int] c2 = c1 + assert c1 == c2 + c1.insert(3) + assert c1 != c2 + c1.erase(3) + assert c1 == c2 + + def test_insert_erase(self): + cdef THashSet[TString] tmp + self.assertTrue(tmp.insert("one").second) + self.assertFalse(tmp.insert("one").second) + self.assertTrue(tmp.insert("two").second) + cdef TString one = "one" + cdef TString two = "two" + self.assertEqual(tmp.erase(one), 1) + self.assertEqual(tmp.erase(two), 1) + self.assertEqual(tmp.size(), 0) + self.assertTrue(tmp.empty()) + + def test_iterators_and_find(self): + cdef THashSet[TString] tmp + self.assertTrue(tmp.begin() == tmp.end()) + self.assertTrue(tmp.find("1") == tmp.end()) + tmp.insert("1") + self.assertTrue(tmp.begin() != tmp.end()) + cdef THashSet[TString].iterator it = tmp.find("1") + self.assertTrue(it != tmp.end()) + self.assertEqual(deref(it), "1") + |