@@ -46,7 +46,7 @@ impl CTestTemplate {
4646/// Stores all information necessary for generation of tests for all items.
4747#[ derive( Clone , Debug , Default ) ]
4848pub ( crate ) struct TestTemplate {
49- pub const_cstr_tests : Vec < TestCstr > ,
49+ pub const_cstr_tests : Vec < TestCStr > ,
5050 pub const_tests : Vec < TestConst > ,
5151 pub test_idents : Vec < BoxStr > ,
5252}
@@ -76,28 +76,29 @@ impl TestTemplate {
7676 && path. path . segments . last ( ) . unwrap ( ) . ident == "c_char"
7777 && ptr. mutability . is_none ( )
7878 {
79- let item = TestCstr {
80- test_ident : cstr_test_ident ( constant. ident ( ) ) ,
81- rust_ident : constant. ident ( ) . into ( ) ,
82- c_ident : helper . c_ident ( constant ) . into ( ) ,
83- c_type : helper. c_type ( constant) ? . into ( ) ,
79+ let item = TestCStr {
80+ id : constant. ident ( ) . into ( ) ,
81+ test_name : cstr_test_ident ( constant. ident ( ) ) ,
82+ rust_val : constant . ident ( ) . into ( ) ,
83+ c_val : helper. c_ident ( constant) . into ( ) ,
8484 } ;
8585 const_cstr_tests. push ( item)
8686 } else {
8787 let item = TestConst {
88- test_ident : const_test_ident ( constant. ident ( ) ) ,
89- rust_ident : constant. ident . clone ( ) ,
90- rust_type : constant. ty . to_token_stream ( ) . to_string ( ) . into_boxed_str ( ) ,
91- c_ident : helper. c_ident ( constant) . into ( ) ,
92- c_type : helper. c_type ( constant) ?. into ( ) ,
88+ id : constant. ident ( ) . into ( ) ,
89+ test_name : const_test_ident ( constant. ident ( ) ) ,
90+ rust_val : constant. ident . clone ( ) ,
91+ rust_ty : constant. ty . to_token_stream ( ) . to_string ( ) . into_boxed_str ( ) ,
92+ c_val : helper. c_ident ( constant) . into ( ) ,
93+ c_ty : helper. c_type ( constant) ?. into ( ) ,
9394 } ;
9495 const_tests. push ( item)
9596 }
9697 }
9798
9899 let mut test_idents = vec ! [ ] ;
99- test_idents. extend ( const_cstr_tests. iter ( ) . map ( |test| test. test_ident . clone ( ) ) ) ;
100- test_idents. extend ( const_tests. iter ( ) . map ( |test| test. test_ident . clone ( ) ) ) ;
100+ test_idents. extend ( const_cstr_tests. iter ( ) . map ( |test| test. test_name . clone ( ) ) ) ;
101+ test_idents. extend ( const_tests. iter ( ) . map ( |test| test. test_name . clone ( ) ) ) ;
101102
102103 Ok ( Self {
103104 const_cstr_tests,
@@ -107,23 +108,35 @@ impl TestTemplate {
107108 }
108109}
109110
111+ /* Many test structures have the following fields:
112+ *
113+ * - `test_name`: The function name.
114+ * - `id`: An identifier that can be used to create functions related to this type without conflict,
115+ * usually also part of `test_name`.
116+ * - `rust_val`: Identifier for a Rust value, with path qualifications if needed.
117+ * - `rust_ty`: The Rust type of the relevant item, with path qualifications if needed.
118+ * - `c_val`: Identifier for a C value (e.g. `#define`)
119+ * - `c_ty`: The C type of the constant, qualified with `struct` or `union` if needed.
120+ */
121+
110122/// Information required to test a constant CStr.
111123#[ derive( Clone , Debug ) ]
112- pub ( crate ) struct TestCstr {
113- pub ( crate ) test_ident : BoxStr ,
114- pub ( crate ) rust_ident : BoxStr ,
115- pub ( crate ) c_ident : BoxStr ,
116- pub ( crate ) c_type : BoxStr ,
124+ pub ( crate ) struct TestCStr {
125+ pub test_name : BoxStr ,
126+ pub id : BoxStr ,
127+ pub rust_val : BoxStr ,
128+ pub c_val : BoxStr ,
117129}
118130
119131/// Information required to test a constant.
120132#[ derive( Clone , Debug ) ]
121133pub ( crate ) struct TestConst {
122- pub ( crate ) test_ident : BoxStr ,
123- pub ( crate ) rust_ident : BoxStr ,
124- pub ( crate ) rust_type : BoxStr ,
125- pub ( crate ) c_ident : BoxStr ,
126- pub ( crate ) c_type : BoxStr ,
134+ pub test_name : BoxStr ,
135+ pub id : BoxStr ,
136+ pub rust_val : BoxStr ,
137+ pub c_val : BoxStr ,
138+ pub rust_ty : BoxStr ,
139+ pub c_ty : BoxStr ,
127140}
128141
129142/// The Rust name of the cstr test.
0 commit comments