@@ -180,7 +180,7 @@ mod tests {
180180 use codegen_sdk_common:: parser:: TypeDefinition ;
181181
182182 use super :: * ;
183- use crate :: test_util:: get_language_no_nodes;
183+ use crate :: test_util:: { get_language_no_nodes, snapshot_tokens } ;
184184 fn create_test_field_definition ( name : & str , multiple : bool , required : bool ) -> FieldDefinition {
185185 FieldDefinition {
186186 types : vec ! [ TypeDefinition {
@@ -249,74 +249,35 @@ mod tests {
249249 let field_definition = create_test_field_definition ( "test_type" , false , true ) ;
250250 let language = get_language_no_nodes ( ) ;
251251 let field = Field :: new ( "test_node" , "test_field" , & field_definition, & language) ;
252-
253- assert_eq ! (
254- field. get_struct_field( ) . to_string( ) ,
255- quote! {
256- #[ rkyv( omit_bounds) ]
257- pub test_field: Box <TestType >
258- }
259- . to_string( )
260- ) ;
252+ snapshot_tokens ( & field. get_struct_field ( ) ) ;
261253
262254 // Test optional field
263255 let optional_definition = create_test_field_definition ( "test_type" , false , false ) ;
264- let language = get_language_no_nodes ( ) ;
265256 let optional_field = Field :: new ( "test_node" , "test_field" , & optional_definition, & language) ;
266-
267- assert_eq ! (
268- optional_field. get_struct_field( ) . to_string( ) ,
269- quote! {
270- #[ rkyv( omit_bounds) ]
271- pub test_field: Box <Option <TestType >>
272- }
273- . to_string( )
274- ) ;
257+ snapshot_tokens ( & optional_field. get_struct_field ( ) ) ;
275258
276259 // Test multiple field
277260 let multiple_definition = create_test_field_definition ( "test_type" , true , true ) ;
278261 let multiple_field = Field :: new ( "test_node" , "test_field" , & multiple_definition, & language) ;
279-
280- assert_eq ! (
281- multiple_field. get_struct_field( ) . to_string( ) ,
282- quote! {
283- #[ rkyv( omit_bounds) ]
284- pub test_field: Vec <TestType >
285- }
286- . to_string( )
287- ) ;
262+ snapshot_tokens ( & multiple_field. get_struct_field ( ) ) ;
288263 }
289264
290265 #[ test]
291266 fn test_get_constructor_field ( ) {
292267 let field_definition = create_test_field_definition ( "test_type" , false , true ) ;
293268 let language = get_language_no_nodes ( ) ;
294269 let field = Field :: new ( "test_node" , "test_field" , & field_definition, & language) ;
295-
296- assert_eq ! (
297- field. get_constructor_field( ) . to_string( ) ,
298- quote!( test_field: Box :: new( get_child_by_field_name( & node, "test_field" , buffer) ?) )
299- . to_string( )
300- ) ;
270+ snapshot_tokens ( & field. get_constructor_field ( ) ) ;
301271
302272 // Test optional field
303273 let optional_definition = create_test_field_definition ( "test_type" , false , false ) ;
304274 let optional_field = Field :: new ( "test_node" , "test_field" , & optional_definition, & language) ;
305-
306- assert_eq ! (
307- optional_field. get_constructor_field( ) . to_string( ) ,
308- quote!( test_field: Box :: new( get_optional_child_by_field_name( & node, "test_field" , buffer) ?) ) . to_string( )
309- ) ;
275+ snapshot_tokens ( & optional_field. get_constructor_field ( ) ) ;
310276
311277 // Test multiple field
312278 let multiple_definition = create_test_field_definition ( "test_type" , true , true ) ;
313279 let multiple_field = Field :: new ( "test_node" , "test_field" , & multiple_definition, & language) ;
314-
315- assert_eq ! (
316- multiple_field. get_constructor_field( ) . to_string( ) ,
317- quote!( test_field: get_multiple_children_by_field_name( & node, "test_field" , buffer) ?)
318- . to_string( )
319- ) ;
280+ snapshot_tokens ( & multiple_field. get_constructor_field ( ) ) ;
320281 }
321282
322283 #[ test]
0 commit comments