Skip to content

Commit 1e34a01

Browse files
committed
expand the test
1 parent 38fb112 commit 1e34a01

1 file changed

Lines changed: 26 additions & 19 deletions

File tree

Framework/test/testCustomParameters.cxx

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -206,27 +206,34 @@ TEST_CASE("test_load_from_ptree")
206206
CHECK(cp.at("myOwnKey1", "PHYSICS") == "myOwnValue1b");
207207
CHECK(cp.atOptional("asdf").has_value() == false);
208208

209-
string json = R"""(
210-
[
211-
{
212-
"name": "mean_of_histogram",
213-
"title": "Mean trend of the example histogram",
214-
"graphAxisLabel": "Mean X:time",
215-
"graphYRange": "0:10000",
216-
"graphs" : [
217-
{
218-
"name": "mean_trend",
219-
"title": "mean trend",
220-
"varexp": "example.mean:time",
221-
"selection": "",
222-
"option": "*L PLC PMC"
223-
}
224-
]
225-
}
226-
]
227-
)""";
228209
auto value = cp.getOptionalPtree("myOwnKey3");
229210
CHECK(value.has_value() == true);
211+
212+
// Check that it's an array with 1 element
213+
std::size_t arraySize = std::distance(value->begin(), value->end());
214+
CHECK(arraySize == 1);
215+
216+
// Get the first (and only) element of the array
217+
auto firstElement = value->begin()->second;
218+
219+
// Check the top-level properties
220+
CHECK(firstElement.get<string>("name") == "mean_of_histogram");
221+
CHECK(firstElement.get<string>("title") == "Mean trend of the example histogram");
222+
CHECK(firstElement.get<string>("graphAxisLabel") == "Mean X:time");
223+
CHECK(firstElement.get<string>("graphYRange") == "0:10000");
224+
225+
// Check the graphs array
226+
auto graphs = firstElement.get_child("graphs");
227+
std::size_t graphsSize = std::distance(graphs.begin(), graphs.end());
228+
CHECK(graphsSize == 1);
229+
230+
// Check the first graph properties
231+
auto firstGraph = graphs.begin()->second;
232+
CHECK(firstGraph.get<string>("name") == "mean_trend");
233+
CHECK(firstGraph.get<string>("title") == "mean trend");
234+
CHECK(firstGraph.get<string>("varexp") == "example.mean:time");
235+
CHECK(firstGraph.get<string>("selection") == "");
236+
CHECK(firstGraph.get<string>("option") == "*L PLC PMC");
230237
}
231238

232239
TEST_CASE("test_default_if_not_found_at_optional")

0 commit comments

Comments
 (0)