#include <catch2/catch_test_macros.hpp>
#include "config.hpp"
#include <iostream>

TEST_CASE("confirm basic config loader ops", "[config]") {
  Config::set_base_dir("./");
  Config config("assets/devices.json");
  auto data_list = config.json();
  auto the_keys = config.keys();

  REQUIRE(the_keys.size() > 0);

  for(auto& [key, data] : data_list.items()) {
    auto wide1 = config.wstring(key, "name");
    auto& comps = data["components"];

    for(auto& comp_data : comps) {
      REQUIRE(comp_data.contains("_type"));
    }
  }

  Config indexed("tests/config_test.json");
  auto& test_0 = indexed[0];
  REQUIRE(test_0["test"] == 0);

  auto& test_1 = indexed[1];
  REQUIRE(test_1["test"] == 1);
}
