File: test_varint.py

package info (click to toggle)
python-clickhouse-driver 0.2.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,516 kB
  • sloc: python: 10,950; pascal: 42; makefile: 31; sh: 3
file content (19 lines) | stat: -rw-r--r-- 485 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from io import BytesIO
from unittest import TestCase

from clickhouse_driver.varint import read_varint, write_varint


class VarIntTestCase(TestCase):
    def test_check_not_negative(self):
        n = 0x9FFFFFFF

        buf = BytesIO()
        write_varint(n, buf)
        val = buf.getvalue()
        self.assertEqual(b'\xFF\xFF\xFF\xFF\t', val)

        buf = BytesIO(val)
        buf.read_one = lambda: ord(buf.read(1))
        m = read_varint(buf)
        self.assertEqual(m, n)