@@ -43,11 +43,15 @@ TEST(ExternalIOTests, TestDirectUnformatted) {
43
43
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
44
44
<< " EndIoStatement() for OpenNewUnit" ;
45
45
46
+ StaticDescriptor<0 > staticDescriptor;
47
+ Descriptor &desc{staticDescriptor.descriptor ()};
48
+ desc.Establish (TypeCode{CFI_type_int8_t}, recl, &buffer, 0 );
49
+ desc.Check ();
50
+
46
51
// INQUIRE(IOLENGTH=) j
47
52
io = IONAME (BeginInquireIoLength)(__FILE__, __LINE__);
48
- ASSERT_TRUE (IONAME (OutputUnformattedBlock)(
49
- io, reinterpret_cast <const char *>(&buffer), recl, 1 ))
50
- << " OutputUnformattedBlock() for InquireIoLength" ;
53
+ ASSERT_TRUE (IONAME (OutputDescriptor)(io, desc))
54
+ << " OutputDescriptor() for InquireIoLength" ;
51
55
ASSERT_EQ (IONAME (GetIoLength)(io), recl) << " GetIoLength" ;
52
56
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
53
57
<< " EndIoStatement() for InquireIoLength" ;
@@ -59,24 +63,23 @@ TEST(ExternalIOTests, TestDirectUnformatted) {
59
63
ASSERT_TRUE (IONAME (SetRec)(io, j)) << " SetRec(" << j << ' )' ;
60
64
61
65
buffer = j;
62
- ASSERT_TRUE (IONAME (OutputUnformattedBlock)(
63
- io, reinterpret_cast <const char *>(&buffer), 1 , recl))
64
- << " OutputUnformattedBlock()" ;
66
+ ASSERT_TRUE (IONAME (OutputDescriptor)(io, desc))
67
+ << " OutputDescriptor() for Write" ;
65
68
66
69
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
67
- << " EndIoStatement() for OutputUnformattedBlock " ;
70
+ << " EndIoStatement() for Write " ;
68
71
}
69
72
70
73
for (int j{records}; j >= 1 ; --j) {
74
+ buffer = -1 ;
71
75
// READ(UNIT=unit,REC=j) n
72
76
io = IONAME (BeginUnformattedInput)(unit, __FILE__, __LINE__);
73
77
ASSERT_TRUE (IONAME (SetRec)(io, j)) << " SetRec(" << j << ' )' ;
74
- ASSERT_TRUE (IONAME (InputUnformattedBlock)(
75
- io, reinterpret_cast <char *>(&buffer), 1 , recl))
76
- << " InputUnformattedBlock()" ;
78
+ ASSERT_TRUE (IONAME (InputDescriptor)(io, desc))
79
+ << " InputDescriptor() for Read" ;
77
80
78
81
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
79
- << " EndIoStatement() for InputUnformattedBlock " ;
82
+ << " EndIoStatement() for Read " ;
80
83
81
84
ASSERT_EQ (buffer, j) << " Read back " << buffer
82
85
<< " from direct unformatted record " << j
@@ -108,17 +111,21 @@ TEST(ExternalIOTests, TestDirectUnformattedSwapped) {
108
111
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
109
112
<< " EndIoStatement() for OpenNewUnit" ;
110
113
114
+ StaticDescriptor<0 > staticDescriptor;
115
+ Descriptor &desc{staticDescriptor.descriptor ()};
116
+ desc.Establish (TypeCode{CFI_type_int64_t}, recl, &buffer, 0 );
117
+ desc.Check ();
118
+
111
119
static constexpr int records{10 };
112
120
for (int j{1 }; j <= records; ++j) {
113
121
// WRITE(UNIT=unit,REC=j) j
114
122
io = IONAME (BeginUnformattedOutput)(unit, __FILE__, __LINE__);
115
123
ASSERT_TRUE (IONAME (SetRec)(io, j)) << " SetRec(" << j << ' )' ;
116
124
buffer = j;
117
- ASSERT_TRUE (IONAME (OutputUnformattedBlock)(
118
- io, reinterpret_cast <const char *>(&buffer), recl, recl))
119
- << " OutputUnformattedBlock()" ;
125
+ ASSERT_TRUE (IONAME (OutputDescriptor)(io, desc))
126
+ << " OutputDescriptor() for Write" ;
120
127
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
121
- << " EndIoStatement() for OutputUnformattedBlock " ;
128
+ << " EndIoStatement() for Write " ;
122
129
}
123
130
124
131
// OPEN(UNIT=unit,STATUS='OLD',CONVERT='SWAP')
@@ -132,11 +139,10 @@ TEST(ExternalIOTests, TestDirectUnformattedSwapped) {
132
139
// READ(UNIT=unit,REC=j) n
133
140
io = IONAME (BeginUnformattedInput)(unit, __FILE__, __LINE__);
134
141
ASSERT_TRUE (IONAME (SetRec)(io, j)) << " SetRec(" << j << ' )' ;
135
- ASSERT_TRUE (IONAME (InputUnformattedBlock)(
136
- io, reinterpret_cast <char *>(&buffer), recl, recl))
137
- << " InputUnformattedBlock()" ;
142
+ ASSERT_TRUE (IONAME (InputDescriptor)(io, desc))
143
+ << " InputDescriptor() for Read" ;
138
144
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
139
- << " EndIoStatement() for InputUnformattedBlock " ;
145
+ << " EndIoStatement() for Read " ;
140
146
ASSERT_EQ (buffer >> 56 , j)
141
147
<< " Read back " << (buffer >> 56 ) << " from direct unformatted record "
142
148
<< j << " , expected " << j << ' \n ' ;
@@ -169,17 +175,6 @@ TEST(ExternalIOTests, TestSequentialFixedUnformatted) {
169
175
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
170
176
<< " EndIoStatement() for OpenNewUnit" ;
171
177
172
- // INQUIRE(IOLENGTH=) j, ...
173
- io = IONAME (BeginInquireIoLength)(__FILE__, __LINE__);
174
- for (int j{1 }; j <= 3 ; ++j) {
175
- ASSERT_TRUE (IONAME (OutputUnformattedBlock)(
176
- io, reinterpret_cast <const char *>(&buffer), recl, 1 ))
177
- << " OutputUnformattedBlock() for InquireIoLength" ;
178
- }
179
- ASSERT_EQ (IONAME (GetIoLength)(io), 3 * recl) << " GetIoLength" ;
180
- ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
181
- << " EndIoStatement() for InquireIoLength" ;
182
-
183
178
// INQUIRE(IOLENGTH=) j, ...
184
179
StaticDescriptor<0 > staticDescriptor;
185
180
Descriptor &desc{staticDescriptor.descriptor ()};
@@ -200,11 +195,10 @@ TEST(ExternalIOTests, TestSequentialFixedUnformatted) {
200
195
// DO J=1,RECORDS; WRITE(UNIT=unit) j; END DO
201
196
io = IONAME (BeginUnformattedOutput)(unit, __FILE__, __LINE__);
202
197
buffer = j;
203
- ASSERT_TRUE (IONAME (OutputUnformattedBlock)(
204
- io, reinterpret_cast <const char *>(&buffer), recl, recl))
205
- << " OutputUnformattedBlock()" ;
198
+ ASSERT_TRUE (IONAME (OutputDescriptor)(io, desc))
199
+ << " OutputDescriptor() for Write" ;
206
200
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
207
- << " EndIoStatement() for OutputUnformattedBlock " ;
201
+ << " EndIoStatement() for WRITE " ;
208
202
}
209
203
210
204
// REWIND(UNIT=unit)
@@ -215,11 +209,10 @@ TEST(ExternalIOTests, TestSequentialFixedUnformatted) {
215
209
for (int j{1 }; j <= records; ++j) {
216
210
// DO J=1,RECORDS; READ(UNIT=unit) n; check n; END DO
217
211
io = IONAME (BeginUnformattedInput)(unit, __FILE__, __LINE__);
218
- ASSERT_TRUE (IONAME (InputUnformattedBlock)(
219
- io, reinterpret_cast <char *>(&buffer), recl, recl))
220
- << " InputUnformattedBlock()" ;
212
+ ASSERT_TRUE (IONAME (InputDescriptor)(io, desc))
213
+ << " InputDescriptor() for Read" ;
221
214
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
222
- << " EndIoStatement() for InputUnformattedBlock " ;
215
+ << " EndIoStatement() for Read " ;
223
216
ASSERT_EQ (buffer, j) << " Read back " << buffer
224
217
<< " from sequential fixed unformatted record " << j
225
218
<< " , expected " << j << ' \n ' ;
@@ -232,11 +225,10 @@ TEST(ExternalIOTests, TestSequentialFixedUnformatted) {
232
225
<< " EndIoStatement() for Backspace (before read)" ;
233
226
// READ(UNIT=unit) n
234
227
io = IONAME (BeginUnformattedInput)(unit, __FILE__, __LINE__);
235
- ASSERT_TRUE (IONAME (InputUnformattedBlock)(
236
- io, reinterpret_cast <char *>(&buffer), recl, recl))
237
- << " InputUnformattedBlock()" ;
228
+ ASSERT_TRUE (IONAME (InputDescriptor)(io, desc))
229
+ << " InputDescriptor() for Read" ;
238
230
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
239
- << " EndIoStatement() for InputUnformattedBlock " ;
231
+ << " EndIoStatement() for Read " ;
240
232
ASSERT_EQ (buffer, j) << " Read back " << buffer
241
233
<< " from sequential fixed unformatted record " << j
242
234
<< " after backspacing, expected " << j << ' \n ' ;
@@ -275,15 +267,18 @@ TEST(ExternalIOTests, TestSequentialVariableUnformatted) {
275
267
buffer[j] = j;
276
268
}
277
269
270
+ StaticDescriptor<0 > staticDescriptor;
271
+ Descriptor &desc{staticDescriptor.descriptor ()};
272
+
278
273
for (int j{1 }; j <= records; ++j) {
279
274
// DO J=1,RECORDS; WRITE(UNIT=unit) BUFFER(0:j); END DO
280
275
io = IONAME (BeginUnformattedOutput)(unit, __FILE__, __LINE__);
281
- ASSERT_TRUE ( IONAME (OutputUnformattedBlock)(io,
282
- reinterpret_cast < const char *>(&buffer), j * sizeof *buffer,
283
- sizeof *buffer ))
284
- << " OutputUnformattedBlock() " ;
276
+ desc. Establish (TypeCode{ sizeof *buffer}, j * sizeof *buffer, buffer, 0 );
277
+ desc. Check ();
278
+ ASSERT_TRUE ( IONAME (OutputDescriptor)(io, desc ))
279
+ << " OutputDescriptor() for Write " ;
285
280
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
286
- << " EndIoStatement() for OutputUnformattedBlock " ;
281
+ << " EndIoStatement() for Write " ;
287
282
}
288
283
289
284
// REWIND(UNIT=unit)
@@ -293,11 +288,12 @@ TEST(ExternalIOTests, TestSequentialVariableUnformatted) {
293
288
for (int j{1 }; j <= records; ++j) {
294
289
// DO J=1,RECORDS; READ(UNIT=unit) n; check n; END DO
295
290
io = IONAME (BeginUnformattedInput)(unit, __FILE__, __LINE__);
296
- ASSERT_TRUE (IONAME (InputUnformattedBlock)(io,
297
- reinterpret_cast <char *>(&buffer), j * sizeof *buffer, sizeof *buffer))
298
- << " InputUnformattedBlock()" ;
291
+ desc.Establish (TypeCode{sizeof *buffer}, j * sizeof *buffer, buffer, 0 );
292
+ desc.Check ();
293
+ ASSERT_TRUE (IONAME (InputDescriptor)(io, desc))
294
+ << " InputDescriptor() for Read" ;
299
295
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
300
- << " EndIoStatement() for InputUnformattedBlock " ;
296
+ << " EndIoStatement() for Read " ;
301
297
for (int k{0 }; k < j; ++k) {
302
298
ASSERT_EQ (buffer[k], k) << " Read back [" << k << " ]=" << buffer[k]
303
299
<< " from direct unformatted record " << j
@@ -312,9 +308,9 @@ TEST(ExternalIOTests, TestSequentialVariableUnformatted) {
312
308
<< " EndIoStatement() for Backspace (before read)" ;
313
309
// READ(unit=unit) n; check
314
310
io = IONAME (BeginUnformattedInput)(unit, __FILE__, __LINE__);
315
- ASSERT_TRUE ( IONAME (InputUnformattedBlock)(io,
316
- reinterpret_cast < char *>(&buffer), j * sizeof *buffer, sizeof *buffer))
317
- << " InputUnformattedBlock ()" ;
311
+ desc. Establish (TypeCode{ sizeof *buffer}, j * sizeof *buffer, buffer, 0 );
312
+ desc. Check ();
313
+ ASSERT_TRUE ( IONAME (InputDescriptor)(io, desc)) << " InputDescriptor ()" ;
318
314
ASSERT_EQ (IONAME (EndIoStatement)(io), IostatOk)
319
315
<< " EndIoStatement() for InputUnformattedBlock" ;
320
316
for (int k{0 }; k < j; ++k) {
0 commit comments