diff options
author | danila-eremin <danila-eremin@yandex-team.ru> | 2022-02-10 16:46:21 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:21 +0300 |
commit | 9d80afb43be16931e653a688c5e0f585101ff4f8 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/stream | |
parent | 358e631d1a69242d3ae4d6e6b1e4f7581d03133b (diff) | |
download | ydb-9d80afb43be16931e653a688c5e0f585101ff4f8.tar.gz |
Restoring authorship annotation for <danila-eremin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/stream')
-rw-r--r-- | util/stream/output.pxd | 24 | ||||
-rw-r--r-- | util/stream/str.pxd | 24 | ||||
-rw-r--r-- | util/stream/str_ut.pyx | 124 |
3 files changed, 86 insertions, 86 deletions
diff --git a/util/stream/output.pxd b/util/stream/output.pxd index 9e8198167b..2fccc26d9b 100644 --- a/util/stream/output.pxd +++ b/util/stream/output.pxd @@ -1,12 +1,12 @@ -from util.generic.string cimport TStringBuf - - -cdef extern from "<util/stream/output.h>" nogil: - cdef cppclass IOutputStream: - IOutputStream() - void Flush() except+ - void Finish() except+ - - void WriteChar "Write"(char) except+ - void WriteBuf "Write"(const TStringBuf) except+ - void Write(const void*, size_t) except+ +from util.generic.string cimport TStringBuf + + +cdef extern from "<util/stream/output.h>" nogil: + cdef cppclass IOutputStream: + IOutputStream() + void Flush() except+ + void Finish() except+ + + void WriteChar "Write"(char) except+ + void WriteBuf "Write"(const TStringBuf) except+ + void Write(const void*, size_t) except+ diff --git a/util/stream/str.pxd b/util/stream/str.pxd index bfdb071559..76dc16a822 100644 --- a/util/stream/str.pxd +++ b/util/stream/str.pxd @@ -1,12 +1,12 @@ -from util.generic.ptr cimport THolder -from util.generic.string cimport TString, TStringBuf -from util.stream.output cimport IOutputStream - - -cdef extern from "<util/stream/str.h>" nogil: - cdef cppclass TStringOutput(IOutputStream): - TStringOutput() except+ - TStringOutput(TString&) except+ - void Reserve(size_t) except+ - -ctypedef THolder[TStringOutput] TStringOutputPtr +from util.generic.ptr cimport THolder +from util.generic.string cimport TString, TStringBuf +from util.stream.output cimport IOutputStream + + +cdef extern from "<util/stream/str.h>" nogil: + cdef cppclass TStringOutput(IOutputStream): + TStringOutput() except+ + TStringOutput(TString&) except+ + void Reserve(size_t) except+ + +ctypedef THolder[TStringOutput] TStringOutputPtr diff --git a/util/stream/str_ut.pyx b/util/stream/str_ut.pyx index 17bf222250..2ae617303f 100644 --- a/util/stream/str_ut.pyx +++ b/util/stream/str_ut.pyx @@ -1,62 +1,62 @@ -# cython: c_string_type=str, c_string_encoding=utf8 - -from cython.operator cimport dereference - -from util.generic.ptr cimport THolder -from util.generic.string cimport TString, TStringBuf -from util.stream.str cimport TStringOutput, TStringOutputPtr - -import unittest - - -class TestStringOutput(unittest.TestCase): - def test_ctor1(self): - cdef TStringOutput output - - def test_ctor2(self): - cdef TString string - cdef THolder[TStringOutput] string_output = THolder[TStringOutput](new TStringOutput(string)) - - def test_write_char(self): - cdef TString string - cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string)) - - self.assertEqual(string, "") - dereference(string_output.Get()).WriteChar('1') - self.assertEqual(string, "1") - dereference(string_output.Get()).WriteChar('2') - self.assertEqual(string, "12") - dereference(string_output.Get()).WriteChar('3') - self.assertEqual(string, "123") - - def test_write_void(self): - cdef TString string - cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string)) - - self.assertEqual(string, "") - dereference(string_output.Get()).Write("1", 1) - self.assertEqual(string, "1") - dereference(string_output.Get()).Write("2", 1) - self.assertEqual(string, "12") - dereference(string_output.Get()).Write("34", 2) - self.assertEqual(string, "1234") - - def test_write_buf(self): - cdef TString string - cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string)) - - self.assertEqual(string, "") - dereference(string_output.Get()).WriteBuf(TStringBuf("1")) - self.assertEqual(string, "1") - dereference(string_output.Get()).WriteBuf(TStringBuf("2")) - self.assertEqual(string, "12") - dereference(string_output.Get()).WriteBuf(TStringBuf("34")) - self.assertEqual(string, "1234") - - def test_reserve(self): - cdef TString string - cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string)) - self.assertEqual(string, "") - dereference(string_output.Get()).Reserve(50) - self.assertEqual(string, "") - self.assertLessEqual(50, string.capacity()) +# cython: c_string_type=str, c_string_encoding=utf8 + +from cython.operator cimport dereference + +from util.generic.ptr cimport THolder +from util.generic.string cimport TString, TStringBuf +from util.stream.str cimport TStringOutput, TStringOutputPtr + +import unittest + + +class TestStringOutput(unittest.TestCase): + def test_ctor1(self): + cdef TStringOutput output + + def test_ctor2(self): + cdef TString string + cdef THolder[TStringOutput] string_output = THolder[TStringOutput](new TStringOutput(string)) + + def test_write_char(self): + cdef TString string + cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string)) + + self.assertEqual(string, "") + dereference(string_output.Get()).WriteChar('1') + self.assertEqual(string, "1") + dereference(string_output.Get()).WriteChar('2') + self.assertEqual(string, "12") + dereference(string_output.Get()).WriteChar('3') + self.assertEqual(string, "123") + + def test_write_void(self): + cdef TString string + cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string)) + + self.assertEqual(string, "") + dereference(string_output.Get()).Write("1", 1) + self.assertEqual(string, "1") + dereference(string_output.Get()).Write("2", 1) + self.assertEqual(string, "12") + dereference(string_output.Get()).Write("34", 2) + self.assertEqual(string, "1234") + + def test_write_buf(self): + cdef TString string + cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string)) + + self.assertEqual(string, "") + dereference(string_output.Get()).WriteBuf(TStringBuf("1")) + self.assertEqual(string, "1") + dereference(string_output.Get()).WriteBuf(TStringBuf("2")) + self.assertEqual(string, "12") + dereference(string_output.Get()).WriteBuf(TStringBuf("34")) + self.assertEqual(string, "1234") + + def test_reserve(self): + cdef TString string + cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string)) + self.assertEqual(string, "") + dereference(string_output.Get()).Reserve(50) + self.assertEqual(string, "") + self.assertLessEqual(50, string.capacity()) |