@@ -2734,21 +2734,21 @@ TEST_CASE("git_hdf5_sample_structure_test", "[serial][hdf5]")
27342734
27352735TEST_CASE (" git_hdf5_sample_attribute_test" , " [serial][hdf5]" )
27362736{
2737- try
2738- {
2739- Series o = Series (" ../samples/git-sample/data%T.h5" , Access::READ_ONLY);
2740-
2737+ auto verifySeries = [](Series o, bool this_is_the_original_file) {
27412738 REQUIRE (o.openPMD () == " 1.1.0" );
27422739 REQUIRE (o.openPMDextension () == 1 );
27432740 REQUIRE (o.basePath () == " /data/%T/" );
27442741 REQUIRE (o.meshesPath () == " fields/" );
27452742 REQUIRE (o.particlesPath () == " particles/" );
2746- REQUIRE (o.iterationEncoding () == IterationEncoding::fileBased);
2747- REQUIRE (o.iterationFormat () == " data%T.h5" );
2748- REQUIRE (o.name () == " data%T" );
2743+ if (this_is_the_original_file)
2744+ {
2745+ REQUIRE (o.iterationEncoding () == IterationEncoding::fileBased);
2746+ REQUIRE (o.iterationFormat () == " data%T.h5" );
2747+ REQUIRE (o.name () == " data%T" );
27492748
2750- REQUIRE (o.iterations .size () == 5 );
2751- REQUIRE (o.iterations .count (100 ) == 1 );
2749+ REQUIRE (o.iterations .size () == 5 );
2750+ REQUIRE (o.iterations .count (100 ) == 1 );
2751+ }
27522752
27532753 Iteration &iteration_100 = o.iterations [100 ];
27542754 REQUIRE (iteration_100.time <double >() == 3.2847121452090077e-14 );
@@ -2978,6 +2978,30 @@ TEST_CASE("git_hdf5_sample_attribute_test", "[serial][hdf5]")
29782978 REQUIRE (weighting_scalar.getDatatype () == Datatype::DOUBLE);
29792979 REQUIRE (weighting_scalar.getDimensionality () == 1 );
29802980 REQUIRE (weighting_scalar.getExtent () == e);
2981+ };
2982+
2983+ try
2984+ {
2985+ {
2986+ Series o =
2987+ Series (" ../samples/git-sample/data%T.h5" , Access::READ_ONLY);
2988+ verifySeries (o, true );
2989+
2990+ Series fromTemplate (
2991+ " ../samples/initialized_from_git_sample.json" ,
2992+ Access::CREATE,
2993+ R"( json.mode = "template")" );
2994+ auxiliary::initializeFromTemplate (fromTemplate, o, 100 );
2995+ fromTemplate.flush ();
2996+ }
2997+
2998+ {
2999+ Series o (
3000+ " ../samples/initialized_from_git_sample.json" ,
3001+ Access::READ_ONLY,
3002+ R"( json.mode = "template")" );
3003+ verifySeries (o, false );
3004+ }
29813005 }
29823006 catch (no_such_file_error &e)
29833007 {
0 commit comments