@@ -26,16 +26,8 @@ struct Fchar {
26
26
LenT len;
27
27
};
28
28
29
- template <typename ... T> using SubF18 = void (*)(Fchar, Fchar, T...);
30
- template <typename ... T>
31
- using SubF77 = void (*)(char *, char *, T..., LenT, LenT);
32
- template <typename ... T>
33
- void CallSubroutine (SubF18<T...> f, Fchar s1, Fchar s2, T... args) {
34
- f (s1, s2, args...);
35
- }
36
-
37
- template <typename ... T>
38
- void CallSubroutine (SubF77<T...> f, Fchar s1, Fchar s2, T... args) {
29
+ template <typename F, typename ... T>
30
+ void CallSubroutine (F f, Fchar s1, Fchar s2, T... args) {
39
31
f (s1.data , s2.data , args..., s1.len , s2.len );
40
32
}
41
33
@@ -113,29 +105,9 @@ bool Check(const FcharData<Kind> &test, const FcharData<Kind> &ref,
113
105
return true ;
114
106
}
115
107
116
- // Call compiled test subroutine and compare variable afterwards with a
117
- // reference. Compare against result from reference subroutine.
118
- template <int Kind, typename ... T>
119
- bool TestSubroutine (const std::string &testName, SubF18<T...> fooTest,
120
- SubF18<T...> fooRef, const FcharData<Kind> &s1, const FcharData<Kind> &s2,
121
- T... otherArgs) {
122
- // Make copies because data may be modified
123
- FcharData<Kind> testS1{s1}, testS2{s2};
124
- CallSubroutine (fooTest, testS1.getFchar (), testS2.getFchar (), otherArgs...);
125
-
126
- // Compare against reference subroutine
127
- FcharData<Kind> refS1{s1}, refS2{s2};
128
- CallSubroutine (fooRef, refS1.getFchar (), refS2.getFchar (), otherArgs...);
129
-
130
- auto description{testName + " KIND=" + std::to_string (Kind)};
131
- bool result{Check (testS1, refS1, description + " s1" )};
132
- result &= Check (testS2, refS2, description + " s2" );
133
- return result;
134
- }
135
-
136
108
// Compare against precomputed results.
137
- template <int Kind, typename ... T>
138
- bool TestSubroutine (const std::string &testName, SubF18<T...> fooTest,
109
+ template <int Kind, typename F, typename ... T>
110
+ bool TestSubroutine (const std::string &testName, F fooTest,
139
111
const FcharData<Kind> &s1, const FcharData<Kind> &refS1,
140
112
const FcharData<Kind> &s2, const FcharData<Kind> &refS2, T... otherArgs) {
141
113
// Make copies because data may be modified
@@ -176,13 +148,13 @@ extern "C" {
176
148
// CHARACTER(*, K) :: s1, s2
177
149
// s1 = s2
178
150
// END SUBROUTINE
179
- void _QPassign1 (Fchar, Fchar );
180
- void _QPassign2 (Fchar, Fchar );
181
- void _QPassign4 (Fchar, Fchar );
151
+ void _QPassign1 (char *, char *, LenT, LenT );
152
+ void _QPassign2 (char *, char *, LenT, LenT );
153
+ void _QPassign4 (char *, char *, LenT, LenT );
182
154
}
183
155
184
156
template <int Kind, typename Func>
185
- void TestNormalAssignement (Func testedSub, int &tests, int &passed) {
157
+ void TestNormalAssignment (Func testedSub, int &tests, int &passed) {
186
158
auto &s1{Inputs<Kind>::s1};
187
159
auto &s2{Inputs<Kind>::s2};
188
160
auto &s3{Inputs<Kind>::s3};
@@ -221,13 +193,13 @@ extern "C" {
221
193
// INTEGER :: lb, ub
222
194
// s1(lb:ub) = s2
223
195
// END SUBROUTINE
224
- void _QPassign_substring1 (Fchar s1, Fchar s2, int *lb, int *ub);
225
- void _QPassign_substring2 (Fchar, Fchar , int *, int *);
226
- void _QPassign_substring4 (Fchar, Fchar , int *, int *);
196
+ void _QPassign_substring1 (char * s1, char * s2, int *lb, int *ub, LenT, LenT );
197
+ void _QPassign_substring2 (char *, char * , int *, int *, LenT, LenT );
198
+ void _QPassign_substring4 (char *, char * , int *, int *, LenT, LenT );
227
199
}
228
200
229
201
template <int Kind, typename Func>
230
- void TestSubstringAssignement (Func testedSub, int &tests, int &passed) {
202
+ void TestSubstringAssignment (Func testedSub, int &tests, int &passed) {
231
203
auto &s1{Inputs<Kind>::s3};
232
204
auto &s2{Inputs<Kind>::s1};
233
205
int lb{3 };
@@ -257,13 +229,13 @@ extern "C" {
257
229
// INTEGER :: lb
258
230
// s1(lb:) = s2
259
231
// END SUBROUTINE
260
- void _QPassign_overlap1 (Fchar s1, Fchar s2, int *lb);
261
- void _QPassign_overlap2 (Fchar, Fchar , int *);
262
- void _QPassign_overlap4 (Fchar, Fchar , int *);
232
+ void _QPassign_overlap1 (char * s1, char * s2, int *lb, LenT, LenT );
233
+ void _QPassign_overlap2 (char *, char * , int *, LenT, LenT );
234
+ void _QPassign_overlap4 (char *, char * , int *, LenT, LenT );
263
235
}
264
236
265
237
template <int Kind, typename Func>
266
- void TestOverlappingAssignement (Func testedSub, int &tests, int &passed) {
238
+ void TestOverlappingAssignment (Func testedSub, int &tests, int &passed) {
267
239
auto &s1{Inputs<Kind>::s1};
268
240
auto &s2{Inputs<Kind>::s2};
269
241
int lb{2 };
@@ -290,13 +262,13 @@ extern "C" {
290
262
// CHARACTER(l2, K) :: s2
291
263
// s1 = s2
292
264
// END SUBROUTINE
293
- void _QPassign_spec_expr_len1 (Fchar s1, Fchar s2, int *l1, int *l2);
294
- void _QPassign_spec_expr_len2 (Fchar s1, Fchar s2, int *l1, int *l2);
295
- void _QPassign_spec_expr_len4 (Fchar s1, Fchar s2, int *l1, int *l2);
265
+ void _QPassign_spec_expr_len1 (char * s1, char * s2, int *l1, int *l2, LenT, LenT );
266
+ void _QPassign_spec_expr_len2 (char * s1, char * s2, int *l1, int *l2, LenT, LenT );
267
+ void _QPassign_spec_expr_len4 (char * s1, char * s2, int *l1, int *l2, LenT, LenT );
296
268
}
297
269
298
270
template <int Kind, typename Func>
299
- void TestSpecExprLenAssignement (Func testedSub, int &tests, int &passed) {
271
+ void TestSpecExprLenAssignment (Func testedSub, int &tests, int &passed) {
300
272
auto &s1{Inputs<Kind>::s1};
301
273
auto &s2{Inputs<Kind>::s2};
302
274
auto &s3{Inputs<Kind>::s3};
@@ -339,7 +311,7 @@ extern "C" {
339
311
// CHARACTER(*) :: s1, s2
340
312
// s2 = s1 // " another piece of string"
341
313
// END SUBROUTINE
342
- void _QPconcat1 (Fchar s1, Fchar s2 );
314
+ void _QPconcat1 (char * s1, char *s2, LenT, LenT );
343
315
}
344
316
345
317
template <int Kind, typename Func>
@@ -360,21 +332,21 @@ void TestConcat(Func testedSub, int &tests, int &passed) {
360
332
int main (int , char **) {
361
333
int tests{0 }, passed{0 };
362
334
363
- TestNormalAssignement <1 >(_QPassign1, tests, passed);
364
- TestNormalAssignement <2 >(_QPassign2, tests, passed);
365
- TestNormalAssignement <4 >(_QPassign4, tests, passed);
335
+ TestNormalAssignment <1 >(_QPassign1, tests, passed);
336
+ TestNormalAssignment <2 >(_QPassign2, tests, passed);
337
+ TestNormalAssignment <4 >(_QPassign4, tests, passed);
366
338
367
- TestSubstringAssignement <1 >(_QPassign_substring1, tests, passed);
368
- TestSubstringAssignement <2 >(_QPassign_substring2, tests, passed);
369
- TestSubstringAssignement <4 >(_QPassign_substring4, tests, passed);
339
+ TestSubstringAssignment <1 >(_QPassign_substring1, tests, passed);
340
+ TestSubstringAssignment <2 >(_QPassign_substring2, tests, passed);
341
+ TestSubstringAssignment <4 >(_QPassign_substring4, tests, passed);
370
342
371
- TestOverlappingAssignement <1 >(_QPassign_overlap1, tests, passed);
372
- TestOverlappingAssignement <2 >(_QPassign_overlap2, tests, passed);
373
- TestOverlappingAssignement <4 >(_QPassign_overlap4, tests, passed);
343
+ TestOverlappingAssignment <1 >(_QPassign_overlap1, tests, passed);
344
+ TestOverlappingAssignment <2 >(_QPassign_overlap2, tests, passed);
345
+ TestOverlappingAssignment <4 >(_QPassign_overlap4, tests, passed);
374
346
375
- TestSpecExprLenAssignement <1 >(_QPassign_spec_expr_len1, tests, passed);
376
- TestSpecExprLenAssignement <2 >(_QPassign_spec_expr_len2, tests, passed);
377
- TestSpecExprLenAssignement <4 >(_QPassign_spec_expr_len4, tests, passed);
347
+ TestSpecExprLenAssignment <1 >(_QPassign_spec_expr_len1, tests, passed);
348
+ TestSpecExprLenAssignment <2 >(_QPassign_spec_expr_len2, tests, passed);
349
+ TestSpecExprLenAssignment <4 >(_QPassign_spec_expr_len4, tests, passed);
378
350
379
351
TestConcat<1 >(_QPconcat1, tests, passed);
380
352
0 commit comments