File: test_binary.py

package info (click to toggle)
pillow 12.0.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 72,636 kB
  • sloc: python: 49,518; ansic: 38,787; makefile: 302; sh: 168; javascript: 85
file content (24 lines) | stat: -rw-r--r-- 650 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from __future__ import annotations

from PIL import _binary


def test_standard() -> None:
    assert _binary.i8(b"*") == 42
    assert _binary.o8(42) == b"*"


def test_little_endian() -> None:
    assert _binary.i16le(b"\xff\xff\x00\x00") == 65535
    assert _binary.i32le(b"\xff\xff\x00\x00") == 65535

    assert _binary.o16le(65535) == b"\xff\xff"
    assert _binary.o32le(65535) == b"\xff\xff\x00\x00"


def test_big_endian() -> None:
    assert _binary.i16be(b"\x00\x00\xff\xff") == 0
    assert _binary.i32be(b"\x00\x00\xff\xff") == 65535

    assert _binary.o16be(65535) == b"\xff\xff"
    assert _binary.o32be(65535) == b"\x00\x00\xff\xff"