Skip to content

Commit 4009784

Browse files
committed
Add explicit test for lazy parsing
1 parent 116c221 commit 4009784

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

test/SerialIOTest.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,3 +3666,54 @@ TEST_CASE( "extend_dataset", "[serial]" )
36663666
// extendDataset( "h5" );
36673667
#endif
36683668
}
3669+
3670+
3671+
void lazy_parsing( std::string const & extension )
3672+
{
3673+
std::string const basename = "../samples/lazy_parsing/lazy_parsing_";
3674+
// create a single iteration
3675+
{
3676+
Series series( basename + "%T." + extension, Access::CREATE );
3677+
std::vector< float > buffer( 20 );
3678+
std::iota( buffer.begin(), buffer.end(), 0.f );
3679+
auto dataset = series.iterations[ 1000 ].meshes[ "E" ][ "x" ];
3680+
dataset.resetDataset( { Datatype::FLOAT, { 20 } } );
3681+
dataset.storeChunk( buffer, { 0 }, { 20 } );
3682+
series.flush();
3683+
}
3684+
// create some empty pseudo files
3685+
// if the reader tries accessing them it's game over
3686+
{
3687+
for( size_t i = 0; i < 1000; i += 100 )
3688+
{
3689+
std::ofstream file;
3690+
file.open( basename + std::to_string( i ) + "." + extension );
3691+
file.close();
3692+
}
3693+
}
3694+
{
3695+
Series series = SeriesBuilder()
3696+
.filePath( basename + "%T." + extension )
3697+
.access( Access::READ_ONLY )
3698+
.parseLazily();
3699+
auto dataset = series.iterations[ 1000 ]
3700+
.open()
3701+
.meshes[ "E" ][ "x" ]
3702+
.loadChunk< float >( { 0 }, { 20 } );
3703+
series.flush();
3704+
for( size_t i = 0; i < 20; ++i )
3705+
{
3706+
REQUIRE(
3707+
std::abs( dataset.get()[ i ] - float( i ) ) <=
3708+
std::numeric_limits< float >::epsilon() );
3709+
}
3710+
}
3711+
}
3712+
3713+
TEST_CASE( "lazy_parsing", "[serial]" )
3714+
{
3715+
for( auto const & t : testedFileExtensions() )
3716+
{
3717+
lazy_parsing( t );
3718+
}
3719+
}

0 commit comments

Comments
 (0)