File: test_buffer_copy.py

package info (click to toggle)
python-moderngl 5.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,700 kB
  • sloc: python: 15,758; cpp: 14,665; makefile: 14
file content (16 lines) | stat: -rw-r--r-- 541 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

def test_1(ctx):
    buf1 = ctx.buffer(b'abc')
    buf2 = ctx.buffer(reserve=3)
    ctx.copy_buffer(buf2, buf1)
    assert buf2.read() == b'abc'


def test_2(ctx):
    buf1 = ctx.buffer(b'abcxyz123')
    buf2 = ctx.buffer(reserve=12)
    ctx.copy_buffer(buf2, buf1, 3, read_offset=3, write_offset=0)
    ctx.copy_buffer(buf2, buf1, 3, read_offset=0, write_offset=3)
    ctx.copy_buffer(buf2, buf1, 3, read_offset=6, write_offset=6)
    ctx.copy_buffer(buf2, buf1, 3, read_offset=3, write_offset=9)
    assert buf2.read() == b'xyzabc123xyz'