@@ -46,7 +46,7 @@ impl CTestTemplate {
46
46
/// Stores all information necessary for generation of tests for all items.
47
47
#[ derive( Clone , Debug , Default ) ]
48
48
pub ( crate ) struct TestTemplate {
49
- pub const_cstr_tests : Vec < TestCstr > ,
49
+ pub const_cstr_tests : Vec < TestCStr > ,
50
50
pub const_tests : Vec < TestConst > ,
51
51
pub test_idents : Vec < BoxStr > ,
52
52
}
@@ -76,28 +76,29 @@ impl TestTemplate {
76
76
&& path. path . segments . last ( ) . unwrap ( ) . ident == "c_char"
77
77
&& ptr. mutability . is_none ( )
78
78
{
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 ( ) ,
84
84
} ;
85
85
const_cstr_tests. push ( item)
86
86
} else {
87
87
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 ( ) ,
93
94
} ;
94
95
const_tests. push ( item)
95
96
}
96
97
}
97
98
98
99
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 ( ) ) ) ;
101
102
102
103
Ok ( Self {
103
104
const_cstr_tests,
@@ -107,23 +108,35 @@ impl TestTemplate {
107
108
}
108
109
}
109
110
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
+
110
122
/// Information required to test a constant CStr.
111
123
#[ 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 ,
117
129
}
118
130
119
131
/// Information required to test a constant.
120
132
#[ derive( Clone , Debug ) ]
121
133
pub ( 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 ,
127
140
}
128
141
129
142
/// The Rust name of the cstr test.
0 commit comments