Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: base/environment_unittest.cc

Issue 2836088: base: rename Environment::SetEnv to Environment::SetVar. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/environment.cc ('k') | base/nss_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/environment.h" 5 #include "base/environment.h"
6 #include "base/scoped_ptr.h" 6 #include "base/scoped_ptr.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/platform_test.h" 8 #include "testing/platform_test.h"
9 9
10 typedef PlatformTest EnvironmentTest; 10 typedef PlatformTest EnvironmentTest;
11 11
12 TEST_F(EnvironmentTest, GetEnvVar) { 12 TEST_F(EnvironmentTest, GetEnvVar) {
13 // Every setup should have non-empty PATH... 13 // Every setup should have non-empty PATH...
14 scoped_ptr<base::Environment> env(base::Environment::Create()); 14 scoped_ptr<base::Environment> env(base::Environment::Create());
15 std::string env_value; 15 std::string env_value;
16 EXPECT_TRUE(env->GetEnv("PATH", &env_value)); 16 EXPECT_TRUE(env->GetEnv("PATH", &env_value));
17 EXPECT_NE(env_value, ""); 17 EXPECT_NE(env_value, "");
18 } 18 }
19 19
20 TEST_F(EnvironmentTest, HasVar) { 20 TEST_F(EnvironmentTest, HasVar) {
21 // Every setup should have PATH... 21 // Every setup should have PATH...
22 scoped_ptr<base::Environment> env(base::Environment::Create()); 22 scoped_ptr<base::Environment> env(base::Environment::Create());
23 EXPECT_TRUE(env->HasVar("PATH")); 23 EXPECT_TRUE(env->HasVar("PATH"));
24 } 24 }
25 25
26 TEST_F(EnvironmentTest, SetEnvVar) { 26 TEST_F(EnvironmentTest, SetVar) {
27 scoped_ptr<base::Environment> env(base::Environment::Create()); 27 scoped_ptr<base::Environment> env(base::Environment::Create());
28 28
29 const char kFooUpper[] = "FOO"; 29 const char kFooUpper[] = "FOO";
30 const char kFooLower[] = "foo"; 30 const char kFooLower[] = "foo";
31 EXPECT_TRUE(env->SetEnv(kFooUpper, kFooLower)); 31 EXPECT_TRUE(env->SetVar(kFooUpper, kFooLower));
32 32
33 // Now verify that the environment has the new variable. 33 // Now verify that the environment has the new variable.
34 EXPECT_TRUE(env->HasVar(kFooUpper)); 34 EXPECT_TRUE(env->HasVar(kFooUpper));
35 35
36 std::string var_value; 36 std::string var_value;
37 EXPECT_TRUE(env->GetEnv(kFooUpper, &var_value)); 37 EXPECT_TRUE(env->GetEnv(kFooUpper, &var_value));
38 EXPECT_EQ(var_value, kFooLower); 38 EXPECT_EQ(var_value, kFooLower);
39 } 39 }
40 40
41 TEST_F(EnvironmentTest, UnSetVar) { 41 TEST_F(EnvironmentTest, UnSetVar) {
42 scoped_ptr<base::Environment> env(base::Environment::Create()); 42 scoped_ptr<base::Environment> env(base::Environment::Create());
43 43
44 const char kFooUpper[] = "FOO"; 44 const char kFooUpper[] = "FOO";
45 const char kFooLower[] = "foo"; 45 const char kFooLower[] = "foo";
46 // First set some environment variable. 46 // First set some environment variable.
47 EXPECT_TRUE(env->SetEnv(kFooUpper, kFooLower)); 47 EXPECT_TRUE(env->SetVar(kFooUpper, kFooLower));
48 48
49 // Now verify that the environment has the new variable. 49 // Now verify that the environment has the new variable.
50 EXPECT_TRUE(env->HasVar(kFooUpper)); 50 EXPECT_TRUE(env->HasVar(kFooUpper));
51 51
52 // Finally verify that the environment variable was erased. 52 // Finally verify that the environment variable was erased.
53 EXPECT_TRUE(env->UnSetVar(kFooUpper)); 53 EXPECT_TRUE(env->UnSetVar(kFooUpper));
54 54
55 // And check that the variable has been unset. 55 // And check that the variable has been unset.
56 EXPECT_FALSE(env->HasVar(kFooUpper)); 56 EXPECT_FALSE(env->HasVar(kFooUpper));
57 } 57 }
OLDNEW
« no previous file with comments | « base/environment.cc ('k') | base/nss_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698