summaryrefslogtreecommitdiffstats
path: root/base/environment_unittest.cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-21 00:41:52 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-21 00:41:52 +0000
commitab57ea34e2049ec93d3dbf3f85d8810896f3d505 (patch)
tree25be68dbe77dec3f5cb643ce54a2d97a22934543 /base/environment_unittest.cc
parentd54ce3203dbce1a43e810267d7372e8611a2b627 (diff)
downloadchromium_src-ab57ea34e2049ec93d3dbf3f85d8810896f3d505.zip
chromium_src-ab57ea34e2049ec93d3dbf3f85d8810896f3d505.tar.gz
chromium_src-ab57ea34e2049ec93d3dbf3f85d8810896f3d505.tar.bz2
Add the reverse test to EnvironmentTest.
This test basically test another behavior of the GetVar function. It tries to get a variable by looking for its reverse form. BUG=None TEST=out/Debug/base_unittests --gtest_filter=EnvironmentTest.GetVarReverse. Review URL: http://codereview.chromium.org/3162025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56950 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/environment_unittest.cc')
-rw-r--r--base/environment_unittest.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/base/environment_unittest.cc b/base/environment_unittest.cc
index 5081459..d1ce503 100644
--- a/base/environment_unittest.cc
+++ b/base/environment_unittest.cc
@@ -17,6 +17,34 @@ TEST_F(EnvironmentTest, GetVar) {
EXPECT_NE(env_value, "");
}
+TEST_F(EnvironmentTest, GetVarReverse) {
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ const char* kFooUpper = "FOO";
+ const char* kFooLower = "foo";
+
+ // Set a variable in UPPER case.
+ EXPECT_TRUE(env->SetVar(kFooUpper, kFooLower));
+
+ // And then try to get this variable passing the lower case.
+ std::string env_value;
+ EXPECT_TRUE(env->GetVar(kFooLower, &env_value));
+
+ EXPECT_STREQ(env_value.c_str(), kFooLower);
+
+ EXPECT_TRUE(env->UnSetVar(kFooUpper));
+
+ const char* kBar = "bar";
+ // Now do the opposite, set the variable in the lower case.
+ EXPECT_TRUE(env->SetVar(kFooLower, kBar));
+
+ // And then try to get this variable passing the UPPER case.
+ EXPECT_TRUE(env->GetVar(kFooUpper, &env_value));
+
+ EXPECT_STREQ(env_value.c_str(), kBar);
+
+ EXPECT_TRUE(env->UnSetVar(kFooLower));
+}
+
TEST_F(EnvironmentTest, HasVar) {
// Every setup should have PATH...
scoped_ptr<base::Environment> env(base::Environment::Create());