@@ -114,3 +114,121 @@ TEST(TypeIdentifierTest, AllocatorSize1) {
114
114
Primitive: int32_t
115
115
)" );
116
116
}
117
+
118
+ TEST (TypeIdentifierTest, PassThroughTypes) {
119
+ auto myint = Primitive{Primitive::Kind::Int32};
120
+
121
+ auto myalloc = Class{1 , Class::Kind::Class, " std::allocator" , 1 };
122
+ myalloc.templateParams .push_back (TemplateParam{myint});
123
+ myalloc.functions .push_back (Function{" allocate" });
124
+ myalloc.functions .push_back (Function{" deallocate" });
125
+
126
+ auto container = getVector ();
127
+ container.templateParams .push_back (TemplateParam{myint});
128
+ container.templateParams .push_back (TemplateParam{myalloc});
129
+
130
+ std::vector<ContainerInfo> passThroughTypes;
131
+ passThroughTypes.emplace_back (" std::allocator" , DUMMY_TYPE, " memory" );
132
+
133
+ test (TypeIdentifier::createPass (passThroughTypes), {container}, R"(
134
+ [0] Container: std::vector (size: 24)
135
+ Param
136
+ Primitive: int32_t
137
+ Param
138
+ [1] Class: std::allocator (size: 1)
139
+ Param
140
+ Primitive: int32_t
141
+ Function: allocate
142
+ Function: deallocate
143
+ )" ,
144
+ R"(
145
+ [0] Container: std::vector (size: 24)
146
+ Param
147
+ Primitive: int32_t
148
+ Param
149
+ [1] Container: std::allocator (size: 1)
150
+ Param
151
+ Primitive: int32_t
152
+ )" );
153
+ }
154
+
155
+ TEST (TypeIdentifierTest, ContainerNotReplaced) {
156
+ auto myint = Primitive{Primitive::Kind::Int32};
157
+
158
+ ContainerInfo allocatorInfo{" std::allocator" , DUMMY_TYPE, " memory" };
159
+ auto myalloc = Container{1 , allocatorInfo, 1 };
160
+ myalloc.templateParams .push_back (TemplateParam{myint});
161
+
162
+ auto container = getVector ();
163
+ container.templateParams .push_back (TemplateParam{myint});
164
+ container.templateParams .push_back (TemplateParam{myalloc});
165
+
166
+ test (TypeIdentifier::createPass ({}), {container}, R"(
167
+ [0] Container: std::vector (size: 24)
168
+ Param
169
+ Primitive: int32_t
170
+ Param
171
+ [1] Container: std::allocator (size: 1)
172
+ Param
173
+ Primitive: int32_t
174
+ )" ,
175
+ R"(
176
+ [0] Container: std::vector (size: 24)
177
+ Param
178
+ Primitive: int32_t
179
+ Param
180
+ Dummy (size: 0, align: 8)
181
+ )" );
182
+ }
183
+
184
+ TEST (TypeIdentifierTest, DummyNotReplaced) {
185
+ auto myint = Primitive{Primitive::Kind::Int32};
186
+
187
+ auto dummy = Dummy{22 , 0 };
188
+
189
+ auto container = getVector ();
190
+ container.templateParams .push_back (TemplateParam{myint});
191
+ container.templateParams .push_back (TemplateParam{dummy});
192
+
193
+ test (TypeIdentifier::createPass ({}), {container}, R"(
194
+ [0] Container: std::vector (size: 24)
195
+ Param
196
+ Primitive: int32_t
197
+ Param
198
+ Dummy (size: 22)
199
+ )" ,
200
+ R"(
201
+ [0] Container: std::vector (size: 24)
202
+ Param
203
+ Primitive: int32_t
204
+ Param
205
+ Dummy (size: 22)
206
+ )" );
207
+ }
208
+
209
+ TEST (TypeIdentifierTest, DummyAllocatorNotReplaced) {
210
+ auto myint = Primitive{Primitive::Kind::Int32};
211
+
212
+ auto dummy = DummyAllocator{myint, 22 , 0 };
213
+
214
+ auto container = getVector ();
215
+ container.templateParams .push_back (TemplateParam{myint});
216
+ container.templateParams .push_back (TemplateParam{dummy});
217
+
218
+ test (TypeIdentifier::createPass ({}), {container}, R"(
219
+ [0] Container: std::vector (size: 24)
220
+ Param
221
+ Primitive: int32_t
222
+ Param
223
+ DummyAllocator (size: 22)
224
+ Primitive: int32_t
225
+ )" ,
226
+ R"(
227
+ [0] Container: std::vector (size: 24)
228
+ Param
229
+ Primitive: int32_t
230
+ Param
231
+ DummyAllocator (size: 22)
232
+ Primitive: int32_t
233
+ )" );
234
+ }
0 commit comments