Warning, file /acts/Tests/UnitTests/Plugins/Json/MaterialMapJsonConverterTests.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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/Utilities/Logger.hpp"
0013 #include "ActsPlugins/Json/IVolumeMaterialJsonDecorator.hpp"
0014 #include "ActsPlugins/Json/MaterialMapJsonConverter.hpp"
0015 #include "ActsTests/CommonHelpers/DataDirectory.hpp"
0016
0017 #include <fstream>
0018 #include <memory>
0019
0020 #include <nlohmann/json.hpp>
0021
0022 namespace Acts {
0023 class IVolumeMaterial;
0024 }
0025
0026 using namespace Acts;
0027
0028 class DummyDecorator : public IVolumeMaterialJsonDecorator {
0029 public:
0030 void decorate([[maybe_unused]] const ISurfaceMaterial &material,
0031 [[maybe_unused]] nlohmann::json &json) const override {};
0032
0033 void decorate([[maybe_unused]] const IVolumeMaterial &material,
0034 [[maybe_unused]] nlohmann::json &json) const override {};
0035 };
0036
0037 namespace ActsTests {
0038
0039 BOOST_AUTO_TEST_SUITE(JsonSuite)
0040
0041 BOOST_AUTO_TEST_CASE(RoundtripFromFile) {
0042
0043 std::ifstream refFile(ActsTests::getDataPath("material-map.json"));
0044 nlohmann::json refJson;
0045 refFile >> refJson;
0046
0047 DummyDecorator decorator;
0048
0049 MaterialMapJsonConverter::Config converterCfg;
0050 MaterialMapJsonConverter converter(converterCfg, Logging::INFO);
0051 auto materialMap = converter.jsonToMaterialMaps(refJson);
0052 nlohmann::json encodedJson =
0053 converter.materialMapsToJson(materialMap, &decorator);
0054
0055
0056 BOOST_CHECK_EQUAL(refJson, encodedJson);
0057 }
0058
0059 BOOST_AUTO_TEST_SUITE_END()
0060
0061 }