152
153
g_object_unref (pGsfInput);
156
/**********************
157
* Test WPXFileStream *
158
**********************/
159
input = new WPXFileStream(TMP_FILENAME);
161
CPPUNIT_ASSERT_EQUAL ( false, input->isOLEStream() );
162
CPPUNIT_ASSERT_EQUAL ( (WPXInputStream*) NULL, input->getDocumentOLEStream() );
165
input->seek(0, WPX_SEEK_SET);
166
CPPUNIT_ASSERT ( NULL != input->read(0, numBytesRead) );
167
CPPUNIT_ASSERT_EQUAL ( (size_t) 0, numBytesRead );
168
CPPUNIT_ASSERT_EQUAL ( (long int) 0 , input->tell() );
169
CPPUNIT_ASSERT ( NULL != input->read(1, numBytesRead) );
170
CPPUNIT_ASSERT_EQUAL ( (long int) 1 , input->tell() );
172
input->seek(0, WPX_SEEK_SET);
173
CPPUNIT_ASSERT ( NULL != input->read(50, numBytesRead) );
174
CPPUNIT_ASSERT_EQUAL ( (long int) 8 , input->tell() );
177
input->seek(0, WPX_SEEK_SET);
178
CPPUNIT_ASSERT_EQUAL( (uint8_t) 1 , readU8(input) );
179
CPPUNIT_ASSERT_EQUAL( (uint8_t) 2 , readU8(input) );
180
CPPUNIT_ASSERT_EQUAL( (uint8_t) 3 , readU8(input) );
181
CPPUNIT_ASSERT_EQUAL( (uint8_t) 4 , readU8(input) );
183
input->seek(0, WPX_SEEK_SET);
184
CPPUNIT_ASSERT_EQUAL( (uint16_t) 0x0201 , readU16(input) );
185
CPPUNIT_ASSERT_EQUAL( (uint16_t) 0x0403 , readU16(input) );
187
input->seek(0, WPX_SEEK_SET);
188
u32 = readU32(input);
189
CPPUNIT_ASSERT_EQUAL( (uint32_t) 0x04030201 , u32 );
190
u32 = readU32(input);
191
CPPUNIT_ASSERT_EQUAL( (uint32_t) 0x07060500 , u32 );
193
// test seek(), tell(), atEOS()
194
input->seek(1, WPX_SEEK_SET);
195
CPPUNIT_ASSERT_EQUAL ( (long int) 1 , input->tell() );
197
input->seek(0, WPX_SEEK_SET);
198
CPPUNIT_ASSERT_EQUAL ( (long int) 0 , input->tell() );
200
input->seek(8, WPX_SEEK_SET);
201
CPPUNIT_ASSERT_EQUAL ( (long int) 8 , input->tell() );
203
input->seek(0, WPX_SEEK_SET);
204
for (int i = 0; i < 8; i++)
206
CPPUNIT_ASSERT_EQUAL ( true, input->atEOS() );
208
CPPUNIT_ASSERT_THROW ( readU8(input), FileException );
210
input->seek(-1, WPX_SEEK_SET);
211
CPPUNIT_ASSERT_EQUAL ( (long int) 0, input->tell() );
213
input->seek(8, WPX_SEEK_SET);
214
CPPUNIT_ASSERT_EQUAL ( true, input->atEOS() );
216
input->seek(10000, WPX_SEEK_SET);
217
CPPUNIT_ASSERT( 10000 != input->tell() );
218
CPPUNIT_ASSERT( input->atEOS() );
222
/************************
223
* Test WPXStringStream *
224
************************/
225
input = new WPXStringStream("\1\2\3\4\0\5\6\7", 8);
227
CPPUNIT_ASSERT_EQUAL ( false, input->isOLEStream() );
228
CPPUNIT_ASSERT_EQUAL ( (WPXInputStream*) NULL, input->getDocumentOLEStream() );
231
input->seek(0, WPX_SEEK_SET);
232
CPPUNIT_ASSERT ( NULL != input->read(0, numBytesRead) );
233
CPPUNIT_ASSERT_EQUAL ( (size_t) 0, numBytesRead );
234
CPPUNIT_ASSERT_EQUAL ( (long int) 0 , input->tell() );
235
CPPUNIT_ASSERT ( NULL != input->read(1, numBytesRead) );
236
CPPUNIT_ASSERT_EQUAL ( (long int) 1 , input->tell() );
238
input->seek(0, WPX_SEEK_SET);
239
CPPUNIT_ASSERT ( NULL != input->read(50, numBytesRead) );
240
CPPUNIT_ASSERT_EQUAL ( (long int) 8 , input->tell() );
243
input->seek(0, WPX_SEEK_SET);
244
CPPUNIT_ASSERT_EQUAL( (uint8_t) 1 , readU8(input) );
245
CPPUNIT_ASSERT_EQUAL( (uint8_t) 2 , readU8(input) );
246
CPPUNIT_ASSERT_EQUAL( (uint8_t) 3 , readU8(input) );
247
CPPUNIT_ASSERT_EQUAL( (uint8_t) 4 , readU8(input) );
249
input->seek(0, WPX_SEEK_SET);
250
CPPUNIT_ASSERT_EQUAL( (uint16_t) 0x0201 , readU16(input) );
251
CPPUNIT_ASSERT_EQUAL( (uint16_t) 0x0403 , readU16(input) );
253
input->seek(0, WPX_SEEK_SET);
254
u32 = readU32(input);
255
CPPUNIT_ASSERT_EQUAL( (uint32_t) 0x04030201 , u32 );
256
u32 = readU32(input);
257
CPPUNIT_ASSERT_EQUAL( (uint32_t) 0x07060500 , u32 );
259
// test seek(), tell(), atEOS()
260
input->seek(1, WPX_SEEK_SET);
261
CPPUNIT_ASSERT_EQUAL ( (long int) 1 , input->tell() );
263
input->seek(0, WPX_SEEK_SET);
264
CPPUNIT_ASSERT_EQUAL ( (long int) 0 , input->tell() );
266
input->seek(8, WPX_SEEK_SET);
267
CPPUNIT_ASSERT_EQUAL ( (long int) 8 , input->tell() );
269
input->seek(0, WPX_SEEK_SET);
270
for (int i = 0; i < 8; i++)
272
CPPUNIT_ASSERT_EQUAL ( true, input->atEOS() );
274
CPPUNIT_ASSERT_THROW ( readU8(input), FileException );
276
input->seek(-1, WPX_SEEK_SET);
277
CPPUNIT_ASSERT_EQUAL ( (long int) 0, input->tell() );
279
input->seek(8, WPX_SEEK_SET);
280
CPPUNIT_ASSERT_EQUAL ( true, input->atEOS() );
282
input->seek(10000, WPX_SEEK_SET);
283
CPPUNIT_ASSERT( 10000 != input->tell() );
284
CPPUNIT_ASSERT( input->atEOS() );
156
289
/************************
157
290
* Test WPXMemoryInputStream *