object-introspection/test/integration/std_map_custom_comparator.toml
2023-08-25 15:13:55 +02:00

88 lines
2.4 KiB
TOML

definitions = '''
struct CustomComparator {
bool operator()(const int& left, const int& right) const {
return left < right;
}
};
// static size of map only increases in multiples of 8. So including
// a single double would keep the static size of map the same
struct SmallSizedCustomComparator {
double a;
bool operator()(const int& left, const int& right) const {
return left < right;
}
};
struct BigSizedCustomComparator {
double d[1000];
bool operator()(const int& left, const int& right) const {
return left < right;
}
};
struct Foo {
std::map<int, double> m1;
std::map<int, int, CustomComparator> m2;
std::map<int, int, SmallSizedCustomComparator> m3;
std::map<int, int, BigSizedCustomComparator> m4;
};
struct Foo4 {
std::map<int, int, std::function<bool(const int&, const int&)>> m;
};
'''
includes = ["map", "functional"]
[cases]
[cases.a]
param_types = ["const Foo&"]
setup = '''
Foo foo;
for (int i = 0; i < 3; i++) {
foo.m1[i] = (i * 10);
}
for (int i = 0; i < 5; i++) {
foo.m2[i] = (i * 10);
}
for (int i = 0; i < 7; i++) {
foo.m3[i] = (i * 10);
}
for (int i = 0; i < 9; i++) {
foo.m4[i] = (i * 10);
}
return {foo};
'''
expect_json = '''[{
"staticSize":8184,
"dynamicSize":780,
"members":[
{"name":"m1", "staticSize":48, "dynamicSize":108, "length":3, "capacity":3, "elementStaticSize":36},
{"name":"m2", "staticSize":48, "dynamicSize":160, "length":5, "capacity":5, "elementStaticSize":32},
{"name":"m3", "staticSize":48, "dynamicSize":224, "length":7, "capacity":7, "elementStaticSize":32},
{"name":"m4", "staticSize":8040, "dynamicSize":288, "length":9, "capacity":9, "elementStaticSize":32}
]}]'''
expect_json_v2 = '''[{
"staticSize":8184,
"exclusiveSize":0,
"members":[
{"name":"m1",
"staticSize":48,
"exclusiveSize":48,
"length":3,
"capacity":3,
"members": [
{"name":"[]", "staticSize":48, "exclusiveSize":36},
{},
{}
]},
{"name":"m2", "staticSize":48, "exclusiveSize":48, "length":5, "capacity":5},
{"name":"m3", "staticSize":48, "exclusiveSize":48, "length":7, "capacity":7},
{"name":"m4", "staticSize":8040, "exclusiveSize":8040, "length":9, "capacity":9}
]}]'''