コード例 #1
0
def test_pack_into():
    size = ASCII_SIZE + UTF8_SIZE
    buf = bytearray(size)
    offset = 0

    offset = ScriptDataLongString.pack_into(buf, offset, "ABC", "ascii")
    offset = ScriptDataLongString.pack_into(buf, offset, "日本語")

    assert buf == (ASCII + UTF8)
    assert offset == size
コード例 #2
0
def test_pack_into():
    size = ASCII_SIZE + UTF8_SIZE
    buf = bytearray(size)
    offset = 0

    offset = ScriptDataLongString.pack_into(buf, offset, "ABC", "ascii")
    offset = ScriptDataLongString.pack_into(buf, offset, "日本語")

    assert buf == (ASCII + UTF8)
    assert offset == size
コード例 #3
0
def test_unpack_from():
    buf = ASCII + UTF8 + BROKEN_UTF8
    offset = 0

    val, offset = ScriptDataLongString.unpack_from(buf, offset)
    assert val == "ABC"

    val, offset = ScriptDataLongString.unpack_from(buf, offset)
    assert val == "日本語"

    val, offset = ScriptDataLongString.unpack_from(buf, offset)
    assert val == "日本"
コード例 #4
0
def test_unpack_from():
    buf = ASCII + UTF8 + BROKEN_UTF8
    offset = 0

    val, offset = ScriptDataLongString.unpack_from(buf, offset)
    assert val == "ABC"

    val, offset = ScriptDataLongString.unpack_from(buf, offset)
    assert val == "日本語"

    val, offset = ScriptDataLongString.unpack_from(buf, offset)
    assert val == "日本"
コード例 #5
0
def test_read_broken_utf8(fd):
    assert ScriptDataLongString.read(fd) == "日本"
    assert fd.tell() == BROKEN_UTF8_SIZE
コード例 #6
0
def test_read_utf8(fd):
    assert ScriptDataLongString.read(fd) == "日本語"
    assert fd.tell() == UTF8_SIZE
コード例 #7
0
def test_read_ascii(fd):
    assert ScriptDataLongString.read(fd, "ascii") == "ABC"
    assert fd.tell() == ASCII_SIZE
コード例 #8
0
def test_size_utf8():
    assert ScriptDataLongString.size("日本語") == UTF8_SIZE
コード例 #9
0
def test_size_ascii():
    assert ScriptDataLongString.size("ABC", "ascii") == ASCII_SIZE
コード例 #10
0
def test_read_broken_utf8(fd):
    assert ScriptDataLongString.read(fd) == "日本"
    assert fd.tell() == BROKEN_UTF8_SIZE
コード例 #11
0
def test_read_utf8(fd):
    assert ScriptDataLongString.read(fd) == "日本語"
    assert fd.tell() == UTF8_SIZE
コード例 #12
0
def test_read_ascii(fd):
    assert ScriptDataLongString.read(fd, "ascii") == "ABC"
    assert fd.tell() == ASCII_SIZE
コード例 #13
0
def test_size_utf8():
    assert ScriptDataLongString.size("日本語") == UTF8_SIZE
コード例 #14
0
def test_size_ascii():
    assert ScriptDataLongString.size("ABC", "ascii") == ASCII_SIZE
コード例 #15
0
def test_pack_utf8():
    assert ScriptDataLongString("日本語") == UTF8
コード例 #16
0
def test_pack_ascii():
    assert ScriptDataLongString("ABC", "ascii") == ASCII