config_test.cxx 834 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // config_test.cxx
  3. // pokemon_test_xc
  4. //
  5. // Created by Sam Jaffe on 12/22/18.
  6. // Copyright © 2018 Sam Jaffe. All rights reserved.
  7. //
  8. #include <json/json.h>
  9. #include "stub_config.h"
  10. #include "xcode_gtest_helper.h"
  11. using testing::Eq;
  12. TEST(ConfigTest, ConfigFileLoadAbsolutePath) {
  13. Config cfg("config_test/absolute.cfg.json");
  14. EXPECT_THAT(cfg.resource(""), Eq("/usr/local/lib/engine_test_xc/absolute/"));
  15. }
  16. TEST(ConfigTest, ConfigFileLoadSelfReferencePath) {
  17. Config cfg("config_test/at-config.cfg.json");
  18. std::string const root = Config().resource("config_test");
  19. EXPECT_THAT(cfg.resource(""), Eq(root + "/relative/"));
  20. }
  21. TEST(ConfigTest, ConfigFromJsonCannotPerformAtConfigSubs) {
  22. Json::Value json;
  23. json["resource_path"] = "@config/root";
  24. Config cfg(json);
  25. EXPECT_THAT(cfg.resource(""), Eq("/root/"));
  26. }