EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MaterialMapJsonConverterTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MaterialMapJsonConverterTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
13 
14 #include <fstream>
15 
16 BOOST_AUTO_TEST_SUITE(MaterialMapJsonConverter)
17 
18 BOOST_AUTO_TEST_CASE(RoundtripFromFile) {
19  // read reference map from file
20  std::ifstream refFile(Acts::Test::getDataPath("material-map.json"));
21  nlohmann::json refJson;
22  refFile >> refJson;
23 
24  // convert to the material map and back again
27  auto materialMap = converter.jsonToMaterialMaps(refJson);
28  auto encodedJson = converter.materialMapsToJson(materialMap);
29 
30  // verify identical encoded JSON values
31  BOOST_CHECK_EQUAL(refJson, encodedJson);
32 }
33 
34 BOOST_AUTO_TEST_SUITE_END()