object-introspection/test/integration/thrift_isset.toml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

370 lines
13 KiB
TOML
Raw Normal View History

2022-12-19 14:37:51 +00:00
thrift_definitions = '''
namespace cpp2 ns_thrift_isset
2022-12-19 14:37:51 +00:00
include "thrift/annotation/cpp.thrift"
include "thrift/annotation/thrift.thrift"
struct MyThriftStructUnpacked {
1: optional i32 a;
2: optional i32 b;
3: optional i32 c;
}
struct MyThriftStructUnpackedPadded {
1: optional i32 a;
2: optional i64 b;
3: optional i32 c;
4: optional i64 d;
5: optional i32 e;
6: optional i64 f;
7: optional i32 g;
8: optional i64 h;
13: optional i32 i;
}
2022-12-19 14:37:51 +00:00
@cpp.PackIsset
struct MyThriftStructPacked {
1: optional i32 a;
2: optional i32 b;
3: optional i32 c;
4: optional i32 d;
5: optional i32 e;
6: optional i32 f;
7: optional i32 g;
8: optional i32 h;
9: optional i32 i;
10: optional i32 j;
}
@cpp.PackIsset{atomic = false}
struct MyThriftStructPackedNonAtomic {
1: optional i32 a;
2: optional i32 b;
3: optional i32 c;
4: optional i32 d;
}
struct MyThriftStructOutOfOrder {
3: i32 a;
1: i32 b;
2: i32 c;
}
struct MyThriftStructRequired {
1: required i32 a;
2: optional i32 b;
3: optional i32 c;
4: required i32 d;
5: required i32 e;
6: optional i32 f;
}
struct MyThriftStructBoxed {
@cpp.Ref{type = cpp.RefType.Unique}
1: optional i32 a;
@thrift.Box
2: optional i32 b;
3: optional i32 c;
4: optional i32 d;
5: optional i32 e;
}
'''
raw_definitions = '''
namespace ns_thrift_isset {
2022-12-19 14:37:51 +00:00
MyThriftStructBoxed::MyThriftStructBoxed() :
__fbthrift_field_b(),
__fbthrift_field_c(),
__fbthrift_field_d(),
__fbthrift_field_e() {
}
MyThriftStructBoxed::~MyThriftStructBoxed() {}
MyThriftStructBoxed::MyThriftStructBoxed(MyThriftStructBoxed&& other) noexcept :
2022-12-19 14:37:51 +00:00
__fbthrift_field_a(std::move(other.__fbthrift_field_a)),
__fbthrift_field_b(std::move(other.__fbthrift_field_b)),
__fbthrift_field_c(std::move(other.__fbthrift_field_c)),
__fbthrift_field_d(std::move(other.__fbthrift_field_d)),
__fbthrift_field_e(std::move(other.__fbthrift_field_e)),
__isset(other.__isset) {
}
} // namespace ns_thrift_isset
2022-12-19 14:37:51 +00:00
'''
[cases]
[cases.unpacked]
param_types = ["const MyThriftStructUnpacked&"]
2022-12-19 14:37:51 +00:00
setup = '''
MyThriftStructUnpacked ret;
2022-12-19 14:37:51 +00:00
ret.a_ref() = 1;
ret.c_ref() = 1;
return ret;
'''
features = ["capture-thrift-isset"]
2022-12-19 14:37:51 +00:00
expect_json = '''[{
"staticSize":16,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":true},
{"name":"__isset", "staticSize":3}
]}]'''
expect_json_v2 = '''[{
"staticSize":16,
"exclusiveSize":1,
"size":16,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_b", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_c", "staticSize":4, "is_set":true},
{"name":"__isset", "staticSize":3, "NOT":"is_set"}
]
}]'''
2022-12-19 14:37:51 +00:00
[cases.unpacked_padded]
param_types = ["const MyThriftStructUnpackedPadded&"]
setup = '''
MyThriftStructUnpackedPadded ret;
ret.a_ref() = 1;
ret.c_ref() = 1;
return ret;
'''
features = ["capture-thrift-isset"]
expect_json = '''[{
"staticSize":80,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_b", "staticSize":8, "isset":false},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_d", "staticSize":8, "isset":false},
{"name":"__fbthrift_field_e", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_f", "staticSize":8, "isset":false},
{"name":"__fbthrift_field_g", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_h", "staticSize":8, "isset":false},
{"name":"__fbthrift_field_i", "staticSize":4, "isset":false},
{"name":"__isset", "staticSize":9}
]}]'''
expect_json_v2 = '''[{
"staticSize":80,
"exclusiveSize":19,
"size":80,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_b", "staticSize":8, "is_set":false},
{"name":"__fbthrift_field_c", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_d", "staticSize":8, "is_set":false},
{"name":"__fbthrift_field_e", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_f", "staticSize":8, "is_set":false},
{"name":"__fbthrift_field_g", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_h", "staticSize":8, "is_set":false},
{"name":"__fbthrift_field_i", "staticSize":4, "is_set":false},
{"name":"__isset", "staticSize":9, "NOT":"is_set"}
]
}]'''
2022-12-19 14:37:51 +00:00
[cases.packed]
param_types = ["const MyThriftStructPacked&"]
2022-12-19 14:37:51 +00:00
setup = '''
MyThriftStructPacked ret;
2022-12-19 14:37:51 +00:00
ret.a_ref() = 1;
ret.c_ref() = 1;
ret.d_ref() = 1;
ret.g_ref() = 1;
ret.h_ref() = 1;
ret.j_ref() = 1;
return ret;
'''
features = ["capture-thrift-isset"]
2022-12-19 14:37:51 +00:00
expect_json = '''[{
"staticSize":44,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_d", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_e", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_f", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_g", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_h", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_i", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_j", "staticSize":4, "isset":true},
{"name":"__isset", "staticSize":2}
]}]'''
expect_json_v2 = '''[{
"staticSize":44,
"exclusiveSize":2,
"size":44,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_b", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_c", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_d", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_e", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_f", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_g", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_h", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_i", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_j", "staticSize":4, "is_set":true},
{"name":"__isset", "staticSize":2, "NOT":"is_set"}
]}]'''
2022-12-19 14:37:51 +00:00
[cases.packed_non_atomic]
param_types = ["const MyThriftStructPackedNonAtomic&"]
2022-12-19 14:37:51 +00:00
setup = '''
MyThriftStructPackedNonAtomic ret;
2022-12-19 14:37:51 +00:00
ret.a_ref() = 1;
ret.c_ref() = 1;
return ret;
'''
features = ["capture-thrift-isset"]
2022-12-19 14:37:51 +00:00
expect_json = '''[{
"staticSize":20,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_d", "staticSize":4, "isset":false},
{"name":"__isset", "staticSize":1}
]}]'''
expect_json_v2 = '''[{
"staticSize":20,
"exclusiveSize":3,
"size":20,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_b", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_c", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_d", "staticSize":4, "is_set":false},
{"name":"__isset", "staticSize":1, "NOT":"is_set"}
]}]'''
2022-12-19 14:37:51 +00:00
[cases.out_of_order]
param_types = ["const MyThriftStructOutOfOrder&"]
2022-12-19 14:37:51 +00:00
setup = '''
MyThriftStructOutOfOrder ret;
2022-12-19 14:37:51 +00:00
ret.b_ref() = 1;
return ret;
'''
features = ["capture-thrift-isset"]
2022-12-19 14:37:51 +00:00
expect_json = '''[{
"staticSize":16,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":false},
{"name":"__isset", "staticSize":3}
]}]'''
expect_json_v2 = '''[{
"staticSize":16,
"exclusiveSize":1,
"size":16,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_b", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_c", "staticSize":4, "is_set":false},
{"name":"__isset", "staticSize":3, "NOT":"is_set"}
]}]'''
2022-12-19 14:37:51 +00:00
[cases.required]
param_types = ["const MyThriftStructRequired&"]
2022-12-19 14:37:51 +00:00
setup = '''
MyThriftStructRequired ret;
2022-12-19 14:37:51 +00:00
ret.b_ref() = 1;
ret.f_ref() = 1;
return ret;
'''
features = ["capture-thrift-isset"]
2022-12-19 14:37:51 +00:00
expect_json = '''[{
"staticSize":28,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_b", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_d", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_e", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_f", "staticSize":4, "isset":true},
{"name":"__isset", "staticSize":3}
]}]'''
expect_json_v2 = '''[{
"staticSize":28,
"exclusiveSize":1,
"size":28,
"members":[
{"name":"__fbthrift_field_a", "staticSize":4, "NOT":"is_set"},
{"name":"__fbthrift_field_b", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_c", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_d", "staticSize":4, "NOT":"is_set"},
{"name":"__fbthrift_field_e", "staticSize":4, "NOT":"is_set"},
{"name":"__fbthrift_field_f", "staticSize":4, "is_set":true},
{"name":"__isset", "staticSize":3, "NOT":"is_set"}
]}]'''
2022-12-19 14:37:51 +00:00
[cases.box]
param_types = ["const MyThriftStructBoxed&"]
2022-12-19 14:37:51 +00:00
setup = '''
MyThriftStructBoxed ret;
2022-12-19 14:37:51 +00:00
ret.d_ref() = 1;
ret.e_ref() = 1;
return ret;
'''
features = ["capture-thrift-isset"]
2022-12-19 14:37:51 +00:00
expect_json = '''[{
"staticSize":32,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":8, "NOT":"isset"},
{"name":"__fbthrift_field_b", "staticSize":8, "NOT":"isset"},
{"name":"__fbthrift_field_c", "staticSize":4, "isset":false},
{"name":"__fbthrift_field_d", "staticSize":4, "isset":true},
{"name":"__fbthrift_field_e", "staticSize":4, "isset":true},
{"name":"__isset", "staticSize":3}
]}]'''
expect_json_v2 = '''[{
"staticSize":32,
"exclusiveSize":1,
"size":32,
"members":[
{"name":"__fbthrift_field_a", "staticSize":8, "NOT":"is_set"},
{"name":"__fbthrift_field_b", "staticSize":8, "NOT":"is_set"},
{"name":"__fbthrift_field_c", "staticSize":4, "is_set":false},
{"name":"__fbthrift_field_d", "staticSize":4, "is_set":true},
{"name":"__fbthrift_field_e", "staticSize":4, "is_set":true},
{"name":"__isset", "staticSize":3, "NOT":"is_set"}
]}]'''
2022-12-19 14:37:51 +00:00
[cases.no_capture]
param_types = ["const MyThriftStructBoxed&"]
2022-12-19 14:37:51 +00:00
setup = '''
MyThriftStructBoxed ret;
2022-12-19 14:37:51 +00:00
ret.d_ref() = 1;
ret.e_ref() = 1;
return ret;
'''
expect_json = '''[{
"staticSize":32,
"dynamicSize":0,
"members":[
{"name":"__fbthrift_field_a", "staticSize":8, "NOT":"isset"},
{"name":"__fbthrift_field_b", "staticSize":8, "NOT":"isset"},
{"name":"__fbthrift_field_c", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_d", "staticSize":4, "NOT":"isset"},
{"name":"__fbthrift_field_e", "staticSize":4, "NOT":"isset"},
{"name":"__isset", "staticSize":3}
]}]'''
expect_json_v2 = '''[{
"staticSize":32,
"exclusiveSize":1,
"size":32,
"members":[
{"name":"__fbthrift_field_a", "staticSize":8, "NOT":"is_set"},
{"name":"__fbthrift_field_b", "staticSize":8, "NOT":"is_set"},
{"name":"__fbthrift_field_c", "staticSize":4, "NOT":"is_set"},
{"name":"__fbthrift_field_d", "staticSize":4, "NOT":"is_set"},
{"name":"__fbthrift_field_e", "staticSize":4, "NOT":"is_set"},
{"name":"__isset", "staticSize":3, "NOT":"is_set"}
]}]'''