2022-12-19 14:37:51 +00:00
|
|
|
includes = ["vector"]
|
2023-10-16 18:42:24 +01:00
|
|
|
|
|
|
|
definitions = '''
|
|
|
|
struct SimpleStruct {
|
|
|
|
int a;
|
|
|
|
char b;
|
|
|
|
long long c;
|
|
|
|
};
|
|
|
|
'''
|
|
|
|
|
2022-12-19 14:37:51 +00:00
|
|
|
[cases]
|
|
|
|
[cases.int_empty]
|
|
|
|
param_types = ["const std::vector<int>&"]
|
|
|
|
setup = "return {};"
|
|
|
|
expect_json = '[{"staticSize":24, "dynamicSize":0, "length":0, "capacity":0, "elementStaticSize":4}]'
|
2024-01-03 17:30:31 +00:00
|
|
|
expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "size": 24, "length":0, "capacity":0, "members":[]}]'
|
2022-12-19 14:37:51 +00:00
|
|
|
[cases.int_some]
|
|
|
|
param_types = ["const std::vector<int>&"]
|
|
|
|
setup = "return {{1,2,3}};"
|
|
|
|
expect_json = '[{"staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4}]'
|
2024-01-03 17:30:31 +00:00
|
|
|
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":36,"length":3, "capacity":3, "members":[
|
|
|
|
{"staticSize":4, "exclusiveSize":4, "size":4},
|
|
|
|
{"staticSize":4, "exclusiveSize":4, "size":4},
|
|
|
|
{"staticSize":4, "exclusiveSize":4, "size":4}
|
2023-08-16 20:40:36 +01:00
|
|
|
]}]'''
|
2023-10-16 18:42:24 +01:00
|
|
|
[cases.struct_some]
|
|
|
|
param_types = ["const std::vector<SimpleStruct>&"]
|
|
|
|
setup = "return {{{}, {}, {}}};"
|
|
|
|
expect_json = '[{"staticSize":24, "dynamicSize":48, "length":3, "capacity":3, "elementStaticSize":16}]'
|
2024-01-03 17:30:31 +00:00
|
|
|
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":72, "length":3, "capacity":3, "members":[
|
|
|
|
{"staticSize":16, "exclusiveSize":3, "size":16},
|
|
|
|
{"staticSize":16, "exclusiveSize":3, "size":16},
|
|
|
|
{"staticSize":16, "exclusiveSize":3, "size":16}
|
2023-10-16 18:42:24 +01:00
|
|
|
]}]'''
|
2022-12-19 14:37:51 +00:00
|
|
|
[cases.bool_empty]
|
2022-12-30 22:41:09 +00:00
|
|
|
skip = true # https://github.com/facebookexperimental/object-introspection/issues/14
|
2022-12-19 14:37:51 +00:00
|
|
|
param_types = ["const std::vector<bool>&"]
|
|
|
|
setup = "return {};"
|
|
|
|
expect_json = '[{"staticSize":40, "dynamicSize":0, "length":0, "capacity":0, "elementStaticSize":0.125}]'
|
|
|
|
[cases.bool_some]
|
2022-12-30 22:41:09 +00:00
|
|
|
skip = true # https://github.com/facebookexperimental/object-introspection/issues/14
|
2022-12-19 14:37:51 +00:00
|
|
|
param_types = ["const std::vector<bool>&"]
|
|
|
|
setup = "return {{true, false, true}};"
|
2023-03-03 20:09:51 +00:00
|
|
|
expect_json = '[{"staticSize":40,"dynamicSize":8, "exclusiveSize":40, "length":3, "capacity":64, "elementStaticSize":0.125}]'
|
2022-12-19 14:37:51 +00:00
|
|
|
[cases.vector_int_empty]
|
|
|
|
param_types = ["const std::vector<std::vector<int>>&"]
|
|
|
|
setup = "return {};"
|
|
|
|
expect_json = '[{"staticSize":24, "dynamicSize":0, "length":0, "capacity":0, "elementStaticSize":24}]'
|
2024-01-03 17:30:31 +00:00
|
|
|
expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "size":24, "length":0, "capacity":0, "members":[]}]'
|
2022-12-19 14:37:51 +00:00
|
|
|
[cases.vector_int_some]
|
|
|
|
param_types = ["const std::vector<std::vector<int>>&"]
|
|
|
|
setup = "return {{{1,2,3},{4},{5,6}}};"
|
|
|
|
expect_json = '''[{
|
|
|
|
"staticSize":24,
|
|
|
|
"dynamicSize":96,
|
2023-03-03 20:09:51 +00:00
|
|
|
"exclusiveSize":24,
|
2022-12-19 14:37:51 +00:00
|
|
|
"length":3,
|
|
|
|
"capacity":3,
|
|
|
|
"elementStaticSize":24,
|
|
|
|
"members":[
|
2023-03-03 20:09:51 +00:00
|
|
|
{"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}
|
2022-12-19 14:37:51 +00:00
|
|
|
]}]'''
|
2024-01-03 17:30:31 +00:00
|
|
|
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":120, "length":3, "capacity": 3, "members":[
|
|
|
|
{"staticSize":24, "exclusiveSize":24, "size":36, "length":3, "capacity": 3, "members":[]},
|
|
|
|
{"staticSize":24, "exclusiveSize":24, "size":28, "length":1, "capacity": 1, "members":[]},
|
|
|
|
{"staticSize":24, "exclusiveSize":24, "size":32, "length":2, "capacity": 2, "members":[]}
|
2023-08-16 20:40:36 +01:00
|
|
|
]}]'''
|
2022-12-19 14:37:51 +00:00
|
|
|
[cases.reserve]
|
|
|
|
param_types = ["const std::vector<int>&"]
|
|
|
|
setup = '''
|
|
|
|
std::vector<int> ret = {1,2,3};
|
|
|
|
ret.reserve(10);
|
|
|
|
return ret;
|
|
|
|
'''
|
2023-03-03 20:09:51 +00:00
|
|
|
expect_json = '[{"staticSize":24, "dynamicSize":40, "exclusiveSize":64, "length":3, "capacity":10, "elementStaticSize":4}]'
|
2024-01-03 17:30:31 +00:00
|
|
|
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":52, "size":64, "length":3, "capacity":10, "members":[
|
|
|
|
{"staticSize":4, "exclusiveSize":4, "size":4},
|
|
|
|
{"staticSize":4, "exclusiveSize":4, "size":4},
|
|
|
|
{"staticSize":4, "exclusiveSize":4, "size":4}
|
2023-08-16 20:40:36 +01:00
|
|
|
]}]'''
|