54 lines
1.1 KiB
Python
54 lines
1.1 KiB
Python
import pytest
|
|
|
|
from ..helpers import Suite
|
|
|
|
@pytest.mark.integration_test
|
|
def test_bytes_address():
|
|
code_py = """
|
|
@exported
|
|
def testEntry(f: bytes) -> bytes:
|
|
return f
|
|
"""
|
|
|
|
result = Suite(code_py).run_code(b'This is a test')
|
|
|
|
# THIS DEPENDS ON THE ALLOCATOR
|
|
# A different allocator will return a different value
|
|
assert 20 == result.returned_value
|
|
|
|
@pytest.mark.integration_test
|
|
def test_bytes_length():
|
|
code_py = """
|
|
@exported
|
|
def testEntry(f: bytes) -> i32:
|
|
return len(f)
|
|
"""
|
|
|
|
result = Suite(code_py).run_code(b'This is another test')
|
|
|
|
assert 20 == result.returned_value
|
|
|
|
@pytest.mark.integration_test
|
|
def test_bytes_index():
|
|
code_py = """
|
|
@exported
|
|
def testEntry(f: bytes) -> u8:
|
|
return f[8]
|
|
"""
|
|
|
|
result = Suite(code_py).run_code(b'This is another test')
|
|
|
|
assert 0x61 == result.returned_value
|
|
|
|
@pytest.mark.integration_test
|
|
def test_bytes_index_out_of_bounds():
|
|
code_py = """
|
|
@exported
|
|
def testEntry(f: bytes) -> u8:
|
|
return f[50]
|
|
"""
|
|
|
|
result = Suite(code_py).run_code(b'Short', b'Long' * 100)
|
|
|
|
assert 0 == result.returned_value
|