object-introspection/test/integration/std_list.toml
Jake Hillion 08e2faa90e tbv2: correctly account for list overhead
`std::list` has per element overhead for the individual heap allocations. This
was already calculated in the container implementation but not used. Allocate
the overhead of each element in the `std::list` to the `std::list` itself as
with other sequential containers.

Test Plan:
- CI
- Updated test cases
2024-01-11 15:41:48 +00:00

60 lines
2.7 KiB
TOML

includes = ["list"]
definitions = '''
struct SimpleStruct {
int a;
char b;
long long c;
};
'''
[cases]
[cases.int_empty]
param_types = ["const std::list<int>&"]
setup = "return {};"
expect_json = '[{"staticSize":24, "dynamicSize":0, "length":0, "capacity":0, "elementStaticSize":4}]'
expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "size":24, "length":0, "capacity":0, "members":[]}]'
[cases.int_some]
param_types = ["const std::list<int>&"]
setup = "return {{1,2,3}};"
expect_json = '[{"staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4}]'
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":84, "size":96, "length":3, "capacity":3, "members":[
{"staticSize":4, "exclusiveSize":4, "size":4},
{"staticSize":4, "exclusiveSize":4, "size":4},
{"staticSize":4, "exclusiveSize":4, "size":4}
]}]'''
[cases.struct_some]
param_types = ["const std::list<SimpleStruct>&"]
setup = "return {{{}, {}, {}}};"
expect_json = '[{"staticSize":24, "dynamicSize":48, "length":3, "capacity":3, "elementStaticSize":16}]'
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":72, "size":120, "length":3, "capacity":3, "members":[
{"staticSize":16, "exclusiveSize":3, "size":16},
{"staticSize":16, "exclusiveSize":3, "size":16},
{"staticSize":16, "exclusiveSize":3, "size":16}
]}]'''
[cases.list_int_empty]
param_types = ["const std::list<std::list<int>>&"]
setup = "return {};"
expect_json = '[{"staticSize":24, "dynamicSize":0, "length":0, "capacity":0, "elementStaticSize":24}]'
expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "size":24, "length":0, "capacity":0, "members":[]}]'
[cases.list_int_some]
param_types = ["const std::list<std::list<int>>&"]
setup = "return {{{1,2,3},{4},{5,6}}};"
expect_json = '''[{
"staticSize":24,
"dynamicSize":96,
"exclusiveSize":24,
"length":3,
"capacity":3,
"elementStaticSize":24,
"members":[
{"staticSize":24, "dynamicSize":12, "exclusiveSize":36, "length":3, "capacity":3, "elementStaticSize":4},
{"staticSize":24, "dynamicSize":4, "exclusiveSize":28, "length":1, "capacity":1, "elementStaticSize":4},
{"staticSize":24, "dynamicSize":8, "exclusiveSize":32, "length":2, "capacity":2, "elementStaticSize":4}
]}]'''
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":72, "size":288, "length":3, "capacity": 3, "members":[
{"staticSize":24, "exclusiveSize":84, "size":96, "length":3, "capacity": 3},
{"staticSize":24, "exclusiveSize":44, "size":48, "length":1, "capacity": 1},
{"staticSize":24, "exclusiveSize":64, "size":72, "length":2, "capacity": 2}
]}]'''