@@ -2721,21 +2721,21 @@ TEST_CASE("git_hdf5_sample_structure_test", "[serial][hdf5]")
27212721
27222722TEST_CASE (" git_hdf5_sample_attribute_test" , " [serial][hdf5]" )
27232723{
2724- try
2725- {
2726- Series o = Series (" ../samples/git-sample/data%T.h5" , Access::READ_ONLY);
2727-
2724+ auto verifySeries = [](Series o, bool this_is_the_original_file) {
27282725 REQUIRE (o.openPMD () == " 1.1.0" );
27292726 REQUIRE (o.openPMDextension () == 1 );
27302727 REQUIRE (o.basePath () == " /data/%T/" );
27312728 REQUIRE (o.meshesPath () == " fields/" );
27322729 REQUIRE (o.particlesPath () == " particles/" );
2733- REQUIRE (o.iterationEncoding () == IterationEncoding::fileBased);
2734- REQUIRE (o.iterationFormat () == " data%T.h5" );
2735- REQUIRE (o.name () == " data%T" );
2730+ if (this_is_the_original_file)
2731+ {
2732+ REQUIRE (o.iterationEncoding () == IterationEncoding::fileBased);
2733+ REQUIRE (o.iterationFormat () == " data%T.h5" );
2734+ REQUIRE (o.name () == " data%T" );
27362735
2737- REQUIRE (o.iterations .size () == 5 );
2738- REQUIRE (o.iterations .count (100 ) == 1 );
2736+ REQUIRE (o.iterations .size () == 5 );
2737+ REQUIRE (o.iterations .count (100 ) == 1 );
2738+ }
27392739
27402740 Iteration &iteration_100 = o.iterations [100 ];
27412741 REQUIRE (iteration_100.time <double >() == 3.2847121452090077e-14 );
@@ -2965,6 +2965,30 @@ TEST_CASE("git_hdf5_sample_attribute_test", "[serial][hdf5]")
29652965 REQUIRE (weighting_scalar.getDatatype () == Datatype::DOUBLE);
29662966 REQUIRE (weighting_scalar.getDimensionality () == 1 );
29672967 REQUIRE (weighting_scalar.getExtent () == e);
2968+ };
2969+
2970+ try
2971+ {
2972+ {
2973+ Series o =
2974+ Series (" ../samples/git-sample/data%T.h5" , Access::READ_ONLY);
2975+ verifySeries (o, true );
2976+
2977+ Series fromTemplate (
2978+ " ../samples/initialized_from_git_sample.json" ,
2979+ Access::CREATE,
2980+ R"( json.mode = "template")" );
2981+ auxiliary::initializeFromTemplate (fromTemplate, o, 100 );
2982+ fromTemplate.flush ();
2983+ }
2984+
2985+ {
2986+ Series o (
2987+ " ../samples/initialized_from_git_sample.json" ,
2988+ Access::READ_ONLY,
2989+ R"( json.mode = "template")" );
2990+ verifySeries (o, false );
2991+ }
29682992 }
29692993 catch (no_such_file_error &e)
29702994 {
0 commit comments