Environment redesign and test/examples review. English API revisions
[anna.git] / test / core / main.cpp
index 09d02ce..b6d4c73 100644 (file)
@@ -129,9 +129,17 @@ BOOST_AUTO_TEST_CASE(configuration) {
 
 BOOST_AUTO_TEST_CASE(environment) {
   anna::Environment &env = anna::Environment::instantiate();
-  BOOST_CHECK_THROW(env.getValue("WRONG_ENV_VAR", true /* exception if missing */), anna::RuntimeException);
+  env.initialize();
+  BOOST_CHECK_THROW(env.getValue("WRONG_ENV_VAR", true), anna::RuntimeException); // true => exception if missing
   BOOST_CHECK_THROW(env.getValue(NULL), anna::RuntimeException);
-  BOOST_REQUIRE_EQUAL(env.getValue("HOME"), std::string("/home/eramos"));
+
+  env.setVariable("TEST_VAR", "my test var value");
+  BOOST_REQUIRE_EQUAL(env.getValue("TEST_VAR"), std::string("my test var value"));
+  env.setVariable("TEST_VAR", "my new test var value", false /* no overwritting */);
+  BOOST_REQUIRE_EQUAL(env.getValue("TEST_VAR"), std::string("my test var value"));
+  env.unsetVariable("TEST_VAR");
+  BOOST_REQUIRE_EQUAL(env.getValue("TEST_VAR"), std::string(""));
+
   BOOST_REQUIRE_EQUAL(env.getValue("MISSING_ENV_VAR"), std::string(""));
 }