File: test-ba-slice.py

package info (click to toggle)
python-libtrace 1.6%2Bgit20161027-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,124 kB
  • ctags: 1,357
  • sloc: ansic: 6,890; python: 3,228; makefile: 70; sh: 49
file content (20 lines) | stat: -rw-r--r-- 415 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

import sys
from plt_testing import *

def pba(ba, tag=''):
    sys.stdout.write(tag+get_tag()+" <")
    for n,x in enumerate(ba):
        if n != 0:
            sys.stdout.write(" ")
        test_print("%02x" % x)
    sys.stdout.write(">\n")

ba = bytearray( [1, 2, 3, 4])
pba(ba)

ba2 = bytearray([17, 34])

ba[0:2] = ba2;  pba(ba, get_tag())
ba[1:3] = ba2;  pba(ba, get_tag())
ba[2:4] = ba2;  pba(ba, get_tag())