File indexing completed on 2025-01-18 09:13:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Material/ISurfaceMaterial.hpp"
0012 #include "Acts/Plugins/Json/IVolumeMaterialJsonDecorator.hpp"
0013 #include "Acts/Plugins/Json/MaterialMapJsonConverter.hpp"
0014 #include "Acts/Tests/CommonHelpers/DataDirectory.hpp"
0015 #include "Acts/Utilities/Logger.hpp"
0016
0017 #include <fstream>
0018 #include <memory>
0019
0020 #include <nlohmann/json.hpp>
0021
0022 namespace Acts {
0023 class IVolumeMaterial;
0024 }
0025
0026 class DummyDecorator : public Acts::IVolumeMaterialJsonDecorator {
0027 public:
0028 void decorate([[maybe_unused]] const Acts::ISurfaceMaterial &material,
0029 [[maybe_unused]] nlohmann::json &json) const override {};
0030
0031 void decorate([[maybe_unused]] const Acts::IVolumeMaterial &material,
0032 [[maybe_unused]] nlohmann::json &json) const override {};
0033 };
0034
0035 BOOST_AUTO_TEST_SUITE(MaterialMapJsonConverter)
0036
0037 BOOST_AUTO_TEST_CASE(RoundtripFromFile) {
0038
0039 std::ifstream refFile(Acts::Test::getDataPath("material-map.json"));
0040 nlohmann::json refJson;
0041 refFile >> refJson;
0042
0043 DummyDecorator decorator;
0044
0045 Acts::MaterialMapJsonConverter::Config converterCfg;
0046 Acts::MaterialMapJsonConverter converter(converterCfg, Acts::Logging::INFO);
0047 auto materialMap = converter.jsonToMaterialMaps(refJson);
0048 nlohmann::json encodedJson =
0049 converter.materialMapsToJson(materialMap, &decorator);
0050
0051
0052 BOOST_CHECK_EQUAL(refJson, encodedJson);
0053 }
0054
0055 BOOST_AUTO_TEST_SUITE_END()