-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_slots.py
39 lines (22 loc) · 909 Bytes
/
test_slots.py
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
29
30
31
32
33
34
35
36
37
38
from cstring import cstring
def test_new_from_bytes():
assert cstring(b'hello, world') == cstring('hello, world')
def test_new_from_bytearray():
assert cstring(bytearray('hello, world', 'utf8')) == cstring('hello, world')
def test_new_from_array():
import array
assert cstring(array.array('B', b'hello, world')) == cstring('hello, world')
def test_new_from_memoryview():
assert cstring(memoryview(b'hello, world')) == cstring('hello, world')
def test_new_from_cstring():
assert cstring(cstring('hello, world')) == cstring('hello, world')
def test_str():
result = cstring('hello, world')
assert str(result) == 'hello, world'
def test_repr():
assert repr(cstring('"hello" "world" 🙂')) == repr('"hello" "world" 🙂')
def test_hash():
a = cstring('hello')
b = cstring('hello')
assert a is not b
assert set((a, b)) == set((a,)) == set((b,))