@@ -2726,21 +2726,21 @@ TEST_CASE("git_hdf5_sample_structure_test", "[serial][hdf5]")
27262726
27272727TEST_CASE (" git_hdf5_sample_attribute_test" , " [serial][hdf5]" )
27282728{
2729- try
2730- {
2731- Series o = Series (" ../samples/git-sample/data%T.h5" , Access::READ_ONLY);
2732-
2729+ auto verifySeries = [](Series o, bool this_is_the_original_file) {
27332730 REQUIRE (o.openPMD () == " 1.1.0" );
27342731 REQUIRE (o.openPMDextension () == 1 );
27352732 REQUIRE (o.basePath () == " /data/%T/" );
27362733 REQUIRE (o.meshesPath () == " fields/" );
27372734 REQUIRE (o.particlesPath () == " particles/" );
2738- REQUIRE (o.iterationEncoding () == IterationEncoding::fileBased);
2739- REQUIRE (o.iterationFormat () == " data%T.h5" );
2740- REQUIRE (o.name () == " data%T" );
2735+ if (this_is_the_original_file)
2736+ {
2737+ REQUIRE (o.iterationEncoding () == IterationEncoding::fileBased);
2738+ REQUIRE (o.iterationFormat () == " data%T.h5" );
2739+ REQUIRE (o.name () == " data%T" );
27412740
2742- REQUIRE (o.iterations .size () == 5 );
2743- REQUIRE (o.iterations .count (100 ) == 1 );
2741+ REQUIRE (o.iterations .size () == 5 );
2742+ REQUIRE (o.iterations .count (100 ) == 1 );
2743+ }
27442744
27452745 Iteration &iteration_100 = o.iterations [100 ];
27462746 REQUIRE (iteration_100.time <double >() == 3.2847121452090077e-14 );
@@ -2970,6 +2970,30 @@ TEST_CASE("git_hdf5_sample_attribute_test", "[serial][hdf5]")
29702970 REQUIRE (weighting_scalar.getDatatype () == Datatype::DOUBLE);
29712971 REQUIRE (weighting_scalar.getDimensionality () == 1 );
29722972 REQUIRE (weighting_scalar.getExtent () == e);
2973+ };
2974+
2975+ try
2976+ {
2977+ {
2978+ Series o =
2979+ Series (" ../samples/git-sample/data%T.h5" , Access::READ_ONLY);
2980+ verifySeries (o, true );
2981+
2982+ Series fromTemplate (
2983+ " ../samples/initialized_from_git_sample.json" ,
2984+ Access::CREATE,
2985+ R"( json.mode = "template")" );
2986+ auxiliary::initializeFromTemplate (fromTemplate, o, 100 );
2987+ fromTemplate.flush ();
2988+ }
2989+
2990+ {
2991+ Series o (
2992+ " ../samples/initialized_from_git_sample.json" ,
2993+ Access::READ_ONLY,
2994+ R"( json.mode = "template")" );
2995+ verifySeries (o, false );
2996+ }
29732997 }
29742998 catch (no_such_file_error &e)
29752999 {
0 commit comments