Coverage for tests/bindgen/list_types/test_lists.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-02-20 16:25 +0000

1from pathlib import Path 

2 

3 

4def test_lists(bindgen_testcase): 

5 store, root = bindgen_testcase( 

6 guest_code_dir=Path(__file__).parent, 

7 world_name='lists', 

8 ) 

9 assert root.strings(store, '') == '' 

10 assert root.strings(store, 'a') == 'a' 

11 assert root.strings(store, 'hello world') == 'hello world' 

12 assert root.strings(store, 'hello ⚑ world') == 'hello ⚑ world' 

13 

14 assert root.bytes(store, b'') == b'' 

15 assert root.bytes(store, b'a') == b'a' 

16 assert root.bytes(store, b'\x01\x02') == b'\x01\x02' 

17 

18 assert root.ints(store, []) == [] 

19 assert root.ints(store, [1]) == [1] 

20 assert root.ints(store, [1, 2, 100, 10000]) == [1, 2, 100, 10000] 

21 

22 assert root.string_list(store, []) == [] 

23 assert root.string_list(store, ['']) == [''] 

24 assert root.string_list( 

25 store, ['a', 'b', '', 'd', 'hello'] 

26 ) == ['a', 'b', '', 'd', 'hello']