Skip to content

Commit 7a3cd2d

Browse files
committed
Add tests for exclusive size
1 parent 542f1a6 commit 7a3cd2d

File tree

9 files changed

+57
-20
lines changed

9 files changed

+57
-20
lines changed

test/integration/anonymous.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,24 +162,28 @@ definitions = '''
162162
"isTypedef": true,
163163
"staticSize": 8,
164164
"dynamicSize": 12,
165+
"exclusiveSize": 0,
165166
"members": [{
166167
"name": "",
167168
"typeName": "__anon_struct_0",
168169
"isTypedef": false,
169170
"staticSize": 8,
170171
"dynamicSize": 12,
172+
"exclusiveSize": 0,
171173
"members": [{
172174
"name": "node",
173175
"typeName": "struct Node *",
174176
"staticSize": 8,
175177
"dynamicSize": 12,
178+
"exclusiveSize": 8,
176179
"members": [{
177180
"typeName": "Node",
178181
"staticSize": 12,
182+
"exclusiveSize": 0,
179183
"members": [
180-
{ "name": "a", "staticSize": 4, "dynamicSize": 0 },
181-
{ "name": "b", "staticSize": 4, "dynamicSize": 0 },
182-
{ "name": "c", "staticSize": 4, "dynamicSize": 0 }
184+
{ "name": "a", "staticSize": 4, "exclusiveSize": 4, "dynamicSize": 0 },
185+
{ "name": "b", "staticSize": 4, "exclusiveSize": 4, "dynamicSize": 0 },
186+
{ "name": "c", "staticSize": 4, "exclusiveSize": 4, "dynamicSize": 0 }
183187
]
184188
}]
185189
}]

test/integration/pointers.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,11 @@ definitions = '''
144144
expect_json = '''[{
145145
"staticSize":24,
146146
"dynamicSize":4,
147+
"exclusiveSize":4,
147148
"members":[
148-
{"name":"a", "staticSize":4, "dynamicSize":0},
149-
{"name":"b", "staticSize":8, "dynamicSize":4},
150-
{"name":"c", "staticSize":8, "dynamicSize":0}
149+
{"name":"a", "staticSize":4, "exclusiveSize":4, "dynamicSize":0},
150+
{"name":"b", "staticSize":8, "exclusiveSize":8, "dynamicSize":4},
151+
{"name":"c", "staticSize":8, "exclusiveSize":8, "dynamicSize":0}
151152
]}]'''
152153
[cases.struct_primitive_ptrs_no_follow]
153154
param_types = ["const PrimitivePtrs&"]

test/integration/sorted_vector_set.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ definitions = '''
3434
expect_json = '''[{
3535
"staticSize": 24,
3636
"dynamicSize": 16,
37+
"exclusiveSize": 0,
3738
"length":3,
3839
"capacity":4,
3940
"elementStaticSize":4,
4041
"members": [{
4142
"staticSize": 24,
4243
"dynamicSize": 16,
44+
"exclusiveSize": 40,
4345
"length": 3,
4446
"capacity": 4,
4547
"elementStaticSize": 4

test/integration/std_array.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ includes = ["array", "cstdint", "vector"]
88
{
99
"staticSize": 1,
1010
"dynamicSize": 0,
11+
"exclusiveSize": 1,
1112
"length": 0,
1213
"capacity": 0,
1314
"elementStaticSize": 8
@@ -22,6 +23,7 @@ includes = ["array", "cstdint", "vector"]
2223
{
2324
"staticSize": 8,
2425
"dynamicSize": 0,
26+
"exclusiveSize": 8,
2527
"length": 1,
2628
"capacity": 1,
2729
"elementStaticSize": 8
@@ -70,17 +72,20 @@ includes = ["array", "cstdint", "vector"]
7072
{
7173
"staticSize": 48,
7274
"dynamicSize": 72,
75+
"exclusiveSize": 0,
7376
"length": 2,
7477
"capacity": 2,
7578
"elementStaticSize": 24,
7679
"members": [
7780
{
7881
"staticSize": 24,
79-
"dynamicSize": 40
82+
"dynamicSize": 40,
83+
"exclusiveSize": 64
8084
},
8185
{
8286
"staticSize": 24,
83-
"dynamicSize": 32
87+
"dynamicSize": 32,
88+
"exclusiveSize": 56
8489
}
8590
]
8691
}

test/integration/std_optional.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ includes = ["optional", "cstdint", "vector"]
88
{
99
"staticSize": 16,
1010
"dynamicSize": 0,
11+
"exclusiveSize": 16,
1112
"length": 0,
1213
"capacity": 1,
1314
"elementStaticSize": 8
@@ -22,6 +23,7 @@ includes = ["optional", "cstdint", "vector"]
2223
{
2324
"staticSize": 16,
2425
"dynamicSize": 0,
26+
"exclusiveSize": 16,
2527
"length": 1,
2628
"capacity": 1,
2729
"elementStaticSize": 8
@@ -36,6 +38,7 @@ includes = ["optional", "cstdint", "vector"]
3638
{
3739
"staticSize": 32,
3840
"dynamicSize": 0,
41+
"exclusiveSize": 32,
3942
"length": 0,
4043
"capacity": 1,
4144
"elementStaticSize": 24
@@ -50,13 +53,15 @@ includes = ["optional", "cstdint", "vector"]
5053
{
5154
"staticSize": 32,
5255
"dynamicSize": 40,
56+
"exclusiveSize": 8,
5357
"length": 1,
5458
"capacity": 1,
5559
"elementStaticSize": 24,
5660
"members": [
5761
{
5862
"staticSize": 24,
5963
"dynamicSize": 40,
64+
"exclusiveSize": 64,
6065
"length": 5
6166
}
6267
]

test/integration/std_smart_ptr.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ definitions = '''
1414
{
1515
"staticSize": 8,
1616
"dynamicSize": 0,
17+
"exclusiveSize": 8,
1718
"length": 0,
1819
"capacity": 1,
1920
"elementStaticSize": 8
@@ -56,13 +57,15 @@ definitions = '''
5657
{
5758
"staticSize": 8,
5859
"dynamicSize": 64,
60+
"exclusiveSize": 8,
5961
"length": 1,
6062
"capacity": 1,
6163
"elementStaticSize": 24,
6264
"members": [
6365
{
6466
"staticSize": 24,
65-
"dynamicSize": 40
67+
"dynamicSize": 40,
68+
"exclusiveSize": 64
6669
}
6770
]
6871
}
@@ -159,7 +162,8 @@ definitions = '''
159162
[
160163
{
161164
"staticSize": 16,
162-
"dynamicSize": 0
165+
"dynamicSize": 0,
166+
"exclusiveSize": 16
163167
}
164168
]
165169
'''
@@ -170,7 +174,8 @@ definitions = '''
170174
[
171175
{
172176
"staticSize": 16,
173-
"dynamicSize": 0
177+
"dynamicSize": 0,
178+
"exclusiveSize": 16
174179
}
175180
]
176181
'''

test/integration/std_string.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ includes = ["string"]
1010
"isTypedef": true,
1111
"staticSize": 32,
1212
"dynamicSize": 0,
13+
"exclusiveSize": 0,
1314
"members": [
1415
{
1516
"staticSize": 32,
1617
"dynamicSize": 0,
18+
"exclusiveSize": 32,
1719
"length": 0,
1820
"capacity": 15,
1921
"elementStaticSize": 1
@@ -32,10 +34,12 @@ includes = ["string"]
3234
"isTypedef": true,
3335
"staticSize": 32,
3436
"dynamicSize": 0,
37+
"exclusiveSize": 0,
3538
"members": [
3639
{
3740
"staticSize": 32,
3841
"dynamicSize": 0,
42+
"exclusiveSize": 32,
3943
"length": 6,
4044
"capacity": 15,
4145
"elementStaticSize": 1
@@ -54,10 +58,12 @@ includes = ["string"]
5458
"isTypedef": true,
5559
"staticSize": 32,
5660
"dynamicSize": 26,
61+
"exclusiveSize": 0,
5762
"members": [
5863
{
5964
"staticSize": 32,
6065
"dynamicSize": 26,
66+
"exclusiveSize": 58,
6167
"length": 26,
6268
"capacity": 26,
6369
"elementStaticSize": 1

test/integration/std_variant.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,25 @@ definitions = '''
1414
expect_json = '''[{
1515
"staticSize":16,
1616
"dynamicSize":0,
17+
"exclusiveSize":15,
1718
"length":1,
1819
"capacity":1,
1920
"elementStaticSize":8,
2021
"members":[
21-
{"typeName":"char", "staticSize":1, "dynamicSize":0}
22+
{"typeName":"char", "staticSize":1, "exclusiveSize":1, "dynamicSize":0}
2223
]}]'''
2324
[cases.char_int64_2]
2425
param_types = ["const std::variant<char, int64_t>&"]
2526
setup = "return 1234;"
2627
expect_json = '''[{
2728
"staticSize":16,
2829
"dynamicSize":0,
30+
"exclusiveSize":8,
2931
"length":1,
3032
"capacity":1,
3133
"elementStaticSize":8,
3234
"members":[
33-
{"typeName":"long", "staticSize":8, "dynamicSize":0}
35+
{"typeName":"long", "staticSize":8, "exclusiveSize":8, "dynamicSize":0}
3436
]}]'''
3537

3638
[cases.vector_int_1]
@@ -39,6 +41,7 @@ definitions = '''
3941
expect_json = '''[{
4042
"staticSize":32,
4143
"dynamicSize":12,
44+
"exclusiveSize":8,
4245
"length":1,
4346
"capacity":1,
4447
"elementStaticSize":24,
@@ -47,6 +50,7 @@ definitions = '''
4750
"typeName":"vector<int, std::allocator<int> >",
4851
"staticSize":24,
4952
"dynamicSize":12,
53+
"exclusiveSize":36,
5054
"length":3,
5155
"capacity":3,
5256
"elementStaticSize":4
@@ -77,18 +81,20 @@ definitions = '''
7781
expect_json = '''[{
7882
"staticSize":24,
7983
"dynamicSize":0,
84+
"exclusiveSize":8,
8085
"length":1,
8186
"capacity":1,
8287
"elementStaticSize":16,
8388
"members":[
8489
{
8590
"staticSize":16,
8691
"dynamicSize":0,
92+
"exclusiveSize":8,
8793
"length":1,
8894
"capacity":1,
8995
"elementStaticSize":8,
9096
"members":[
91-
{"typeName":"long", "staticSize":8, "dynamicSize":0}
97+
{"typeName":"long", "staticSize":8, "exclusiveSize":8, "dynamicSize":0}
9298
]
9399
}
94100
]}]'''
@@ -109,6 +115,7 @@ definitions = '''
109115
expect_json = '''[{
110116
"staticSize":8,
111117
"dynamicSize":0,
118+
"exclusiveSize":8,
112119
"length":1,
113120
"capacity":1,
114121
"elementStaticSize":4,
@@ -125,11 +132,12 @@ definitions = '''
125132
expect_json = '''[{
126133
"staticSize":8,
127134
"dynamicSize":0,
135+
"exclusiveSize":7,
128136
"length":1,
129137
"capacity":1,
130138
"elementStaticSize":4,
131139
"members":[
132-
{"typeName":"char", "staticSize":1, "dynamicSize":0}
140+
{"typeName":"char", "staticSize":1, "exclusiveSize":1, "dynamicSize":0}
133141
]}]'''
134142
[cases.256_params_empty]
135143
param_types = ["const std::variant<Thrower,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,char>&"]

test/integration/std_vector.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ includes = ["vector"]
1717
skip = true # https://github.com/facebookexperimental/object-introspection/issues/14
1818
param_types = ["const std::vector<bool>&"]
1919
setup = "return {{true, false, true}};"
20-
expect_json = '[{"staticSize":40,"dynamicSize":8, "length":3, "capacity":64, "elementStaticSize":0.125}]'
20+
expect_json = '[{"staticSize":40,"dynamicSize":8, "exclusiveSize":40, "length":3, "capacity":64, "elementStaticSize":0.125}]'
2121
[cases.vector_int_empty]
2222
param_types = ["const std::vector<std::vector<int>>&"]
2323
setup = "return {};"
@@ -28,13 +28,14 @@ includes = ["vector"]
2828
expect_json = '''[{
2929
"staticSize":24,
3030
"dynamicSize":96,
31+
"exclusiveSize":24,
3132
"length":3,
3233
"capacity":3,
3334
"elementStaticSize":24,
3435
"members":[
35-
{"staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
36-
{"staticSize":24, "dynamicSize":4, "length":1, "capacity":1, "elementStaticSize":4},
37-
{"staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4}
36+
{"staticSize":24, "dynamicSize":12, "exclusiveSize":36, "length":3, "capacity":3, "elementStaticSize":4},
37+
{"staticSize":24, "dynamicSize":4, "exclusiveSize":28, "length":1, "capacity":1, "elementStaticSize":4},
38+
{"staticSize":24, "dynamicSize":8, "exclusiveSize":32, "length":2, "capacity":2, "elementStaticSize":4}
3839
]}]'''
3940
[cases.reserve]
4041
param_types = ["const std::vector<int>&"]
@@ -43,4 +44,4 @@ includes = ["vector"]
4344
ret.reserve(10);
4445
return ret;
4546
'''
46-
expect_json = '[{"staticSize":24, "dynamicSize":40, "length":3, "capacity":10, "elementStaticSize":4}]'
47+
expect_json = '[{"staticSize":24, "dynamicSize":40, "exclusiveSize":64, "length":3, "capacity":10, "elementStaticSize":4}]'

0 commit comments

Comments
 (0)