MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_slice

Function test_slice

extra_tests/snippets/builtin_memoryview.py:35–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34
35def test_slice():
36 b = b"123456789"
37 m = memoryview(b)
38 m2 = memoryview(b)
39 assert m == m
40 assert m == m2
41 assert m.tobytes() == b"123456789"
42 assert m == b
43 assert m[::2].tobytes() == b"13579"
44 assert m[::2] == b"13579"
45 assert m[1::2].tobytes() == b"2468"
46 assert m[::2][1:].tobytes() == b"3579"
47 assert m[::2][1:-1].tobytes() == b"357"
48 assert m[::2][::2].tobytes() == b"159"
49 assert m[::2][1::2].tobytes() == b"37"
50 assert m[::-1].tobytes() == b"987654321"
51 assert m[::-2].tobytes() == b"97531"
52
53
54test_slice()

Callers 1

Calls 1

tobytesMethod · 0.45

Tested by

no test coverage detected