ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JsonConversionTest.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JsonConversionTest.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
11 
12 #include <fstream>
13 #include <ios>
14 #include <iostream>
15 #include <stdexcept>
16 
20 
22 
23 namespace Acts {
24 namespace Test {
25 
26 BOOST_AUTO_TEST_CASE(Json_conversion) {
27  std::stringstream ifj;
28 
30 
31  ifj << "{";
32  ifj << " \"volumes\": {";
33  ifj << " \"2\": {";
34  ifj << " \"Geoid\": \"[ 2 | 0 | 2 | 0 | 0 ]\",";
35  ifj << " \"Name\": \"\",";
36  ifj << " \"layers\": {";
37  ifj << " \"2\": {";
38  ifj << " \"Geoid\": \"[ 2 | 0 | 2 | 0 | 0 ]\",";
39  ifj << " \"representing\": {";
40  ifj << " \"bin0\": [";
41  ifj << " \"binR\",";
42  ifj << " \"open\",";
43  ifj << " 2,";
44  ifj << " [";
45  ifj << " 28.0,";
46  ifj << " 186.0";
47  ifj << " ]";
48  ifj << " ],";
49  ifj << " \"data\": [";
50  ifj << " [";
51  ifj << " [";
52  ifj << " 116.40576171875,";
53  ifj << " 220.39578247070313,";
54  ifj << " 7.115414142608643,";
55  ifj << " 1.42858931477799e+22,";
56  ifj << " 0.003504054620862007,";
57  ifj << " 1.0";
58  ifj << " ],";
59  ifj << " [";
60  ifj << " 431.8612976074219,";
61  ifj << " 1103.45947265625,";
62  ifj << " 11.447914123535156,";
63  ifj << " 4.5373971722490746e+21,";
64  ifj << " 0.0007596652721986175,";
65  ifj << " 1.0";
66  ifj << " ]";
67  ifj << " ]";
68  ifj << " ],";
69  ifj << " \"matSurface\": true,";
70  ifj << " \"type\": \"binned\"";
71  ifj << " }";
72  ifj << " },";
73  ifj << " \"4\": {";
74  ifj << " \"Geoid\": \"[ 2 | 0 | 4 | 0 | 0 ]\",";
75  ifj << " \"representing\": {";
76  ifj << " \"bin0\": [";
77  ifj << " \"binR\",";
78  ifj << " \"open\",";
79  ifj << " 2,";
80  ifj << " [";
81  ifj << " 28.0,";
82  ifj << " 186.0";
83  ifj << " ]";
84  ifj << " ],";
85  ifj << " \"data\": [";
86  ifj << " [";
87  ifj << " [";
88  ifj << " 91.93806457519531,";
89  ifj << " 170.03167724609375,";
90  ifj << " 4.947852611541748,";
91  ifj << " 1.8783701146029598e+22,";
92  ifj << " 0.004517487715929747,";
93  ifj << " 1.0";
94  ifj << " ],";
95  ifj << " [";
96  ifj << " 566.8548583984375,";
97  ifj << " 1606.4842529296875,";
98  ifj << " 10.814791679382324,";
99  ifj << " 5.322017395554306e+21,";
100  ifj << " 0.0005397787317633629,";
101  ifj << " 1.0";
102  ifj << " ]";
103  ifj << " ]";
104  ifj << " ],";
105  ifj << " \"matSurface\": true,";
106  ifj << " \"type\": \"binned\"";
107  ifj << " }";
108  ifj << " }";
109  ifj << " }";
110  ifj << " }";
111  ifj << " }";
112  ifj << "}";
113 
114  json jin;
115  ifj >> jin;
116 
117  Acts::JsonGeometryConverter jmConverter(cfg);
118 
119  auto Map = jmConverter.jsonToMaterialMaps(jin);
120  auto jint = jmConverter.materialMapsToJson(Map);
121 
122  BOOST_CHECK_EQUAL(jin, jint);
123 }
124 
125 } // namespace Test
126 } // namespace Acts