@@ -226,21 +226,45 @@ namespace {
226
226
227
227
TEST_F (GridFSTest, GridFileBuilder) {
228
228
GridFileBuilder gfb (_gfs.get ());
229
- for (int i=0 ; i<DATA_LEN; i+=2 )
230
- gfb.appendChunk (DATA + i, min (2 , DATA_LEN - i));
229
+ size_t totalSize = 0 ;
230
+ for (int i=0 ; i<DATA_LEN; i+=2 ) {
231
+ size_t chunkSize = min (2 , DATA_LEN - i);
232
+ gfb.appendChunk (DATA + i, chunkSize);
233
+ totalSize += chunkSize;
234
+ }
231
235
gfb.buildFile (DATA_NAME);
232
236
GridFile gf = _gfs->findFileByName (DATA_NAME);
233
237
ASSERT_EQUALS (gf.getNumChunks (), 1 );
238
+ ASSERT_EQUALS (gf.getContentLength (), totalSize);
234
239
}
235
240
236
241
TEST_F (GridFSTest, GridFileBuilderMultipleChunks) {
237
242
_gfs->setChunkSize (1 );
238
243
GridFileBuilder gfb (_gfs.get ());
239
- for (int i=0 ; i<DATA_LEN; i+=2 )
240
- gfb.appendChunk (DATA + i, min (2 , DATA_LEN - i));
244
+ size_t total_size = 0 ;
245
+ for (int i=0 ; i<DATA_LEN; i+=2 ) {
246
+ size_t chunk_size = min (2 , DATA_LEN - i);
247
+ gfb.appendChunk (DATA + i, chunk_size);
248
+ total_size += chunk_size;
249
+ }
241
250
gfb.buildFile (DATA_NAME);
242
251
GridFile gf = _gfs->findFileByName (DATA_NAME);
243
252
ASSERT_EQUALS (gf.getNumChunks (), DATA_LEN);
253
+ ASSERT_EQUALS (gf.getContentLength (), total_size);
254
+ }
255
+
256
+ TEST_F (GridFSTest, GridFileBuilderAcrossChunkBoundry) {
257
+ _gfs->setChunkSize (11 );
258
+ GridFileBuilder gfb (_gfs.get ());
259
+ size_t total_size = 0 ;
260
+ for (int i=0 ; i<DATA_LEN; i+=2 ) {
261
+ size_t chunk_size = min (2 , DATA_LEN - i);
262
+ gfb.appendChunk (DATA + i, chunk_size);
263
+ total_size += chunk_size;
264
+ }
265
+ gfb.buildFile (DATA_NAME);
266
+ GridFile gf = _gfs->findFileByName (DATA_NAME);
267
+ ASSERT_EQUALS (gf.getContentLength (), total_size);
244
268
}
245
269
246
270
} // namespace
0 commit comments