std::ifstream i(filename);
i >> jids;
- auto m = to_surface_id_to_layer_map(jids["mappings"]);
-
- if (m.is_ok()) {
- auto i = m.unwrap();
-
- auto jtests = jids.value("tests", json());
-
- std::vector<std::pair<int, int>> tests;
- std::transform(std::cbegin(jtests), std::cend(jtests),
- std::back_inserter(tests), [](json const &j) {
- return std::make_pair(get<int>(j["surface_id"]),
- get<int>(j["expect_layer_id"]));
- });
-
- for (auto sid : tests) {
- if (i.get_layer_for_surface(sid.first).value_or(-1) != sid.second) {
- return Err<surface_id_to_layer_map>("ID Map embedded test failed!");
- }
- }
- }
-
- return m;
+ return to_surface_id_to_layer_map(jids);
}
} // namespace