diff --git a/src/auxiliary/JSON.cpp b/src/auxiliary/JSON.cpp index 386cd438bc..168cab7bf6 100644 --- a/src/auxiliary/JSON.cpp +++ b/src/auxiliary/JSON.cpp @@ -249,7 +249,7 @@ namespace case nlohmann::json::value_t::number_unsigned: return val.get(); case nlohmann::json::value_t::number_float: - return val.get(); + return (long double)val.get(); case nlohmann::json::value_t::binary: return val.get(); case nlohmann::json::value_t::discarded: diff --git a/src/config.cpp b/src/config.cpp index 2b45767df1..ff1a0cb471 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -34,6 +34,7 @@ std::map openPMD::getVariants() return std::map{ {"mpi", bool(openPMD_HAVE_MPI)}, {"json", true}, + {"toml", true}, {"hdf5", bool(openPMD_HAVE_HDF5)}, {"adios1", false}, {"adios2", bool(openPMD_HAVE_ADIOS2)}}; @@ -43,6 +44,7 @@ std::vector openPMD::getFileExtensions() { std::vector fext; fext.emplace_back("json"); + fext.emplace_back("toml"); #if openPMD_HAVE_ADIOS2 fext.emplace_back("bp"); #endif diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 71c0a9b8a3..5bac468525 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -1287,14 +1287,21 @@ TEST_CASE("particle_patches", "[serial]") } } -inline void dtype_test(const std::string &backend) +inline void dtype_test( + const std::string &backend, + std::optional activateTemplateMode = {}) { bool test_long_double = (backend != "json" || sizeof(long double) <= 8) && backend != "toml"; bool test_long_long = (backend != "json" || sizeof(long long) <= 8) && backend != "toml"; { - Series s = Series("../samples/dtype_test." + backend, Access::CREATE); + Series s = activateTemplateMode.has_value() + ? Series( + "../samples/dtype_test." + backend, + Access::CREATE, + activateTemplateMode.value()) + : Series("../samples/dtype_test." + backend, Access::CREATE); bool adios1 = s.backend() == "ADIOS1" || s.backend() == "MPI_ADIOS1"; char c = 'c'; @@ -1424,7 +1431,12 @@ inline void dtype_test(const std::string &backend) } } - Series s = Series("../samples/dtype_test." + backend, Access::READ_ONLY); + Series s = activateTemplateMode.has_value() + ? Series( + "../samples/dtype_test." + backend, + Access::READ_ONLY, + activateTemplateMode.value()) + : Series("../samples/dtype_test." + backend, Access::READ_ONLY); bool adios1 = s.backend() == "ADIOS1" || s.backend() == "MPI_ADIOS1"; REQUIRE(s.getAttribute("char").get() == 'c'); @@ -1502,6 +1514,10 @@ inline void dtype_test(const std::string &backend) REQUIRE(s.getAttribute("bool").get() == true); REQUIRE(s.getAttribute("boolF").get() == false); + if (activateTemplateMode.has_value()) + { + return; + } // same implementation types (not necessary aliases) detection #if !defined(_MSC_VER) REQUIRE(s.getAttribute("short").dtype == Datatype::SHORT); diff --git a/test/python/unittest/API/APITest.py b/test/python/unittest/API/APITest.py index 0aa71cf7a8..72b099c5ee 100644 --- a/test/python/unittest/API/APITest.py +++ b/test/python/unittest/API/APITest.py @@ -359,7 +359,8 @@ def attributeRoundTrip(self, file_ending): # c_types self.assertEqual(series.get_attribute("byte_c"), 30) self.assertEqual(series.get_attribute("ubyte_c"), 50) - if file_ending != "json": # TODO: returns [100] instead of 100 in json + # TODO: returns [100] instead of 100 in json + if file_ending != "json" and file_ending != "toml": self.assertEqual(chr(series.get_attribute("char_c")), 'd') self.assertEqual(series.get_attribute("int16_c"), 2) self.assertEqual(series.get_attribute("int32_c"), 3) @@ -1824,7 +1825,7 @@ def testIterator(self): self.makeIteratorRoundTrip(b, backend_filesupport[b]) def makeAvailableChunksRoundTrip(self, ext): - if ext == "h5": + if ext == "h5" or ext == "toml": return name = "../samples/available_chunks_python." + ext write = io.Series(