diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/testing/common/ut/scope_ut.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/testing/common/ut/scope_ut.cpp')
-rw-r--r-- | library/cpp/testing/common/ut/scope_ut.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/library/cpp/testing/common/ut/scope_ut.cpp b/library/cpp/testing/common/ut/scope_ut.cpp new file mode 100644 index 0000000000..4fb82c2466 --- /dev/null +++ b/library/cpp/testing/common/ut/scope_ut.cpp @@ -0,0 +1,28 @@ +#include <library/cpp/testing/common/scope.h> + +#include <util/system/env.h> + +#include <library/cpp/testing/gtest/gtest.h> + +TEST(TScopedEnvironment, SingleValue) { + auto before = GetEnv("ARCADIA_SOURCE_ROOT"); + { + NTesting::TScopedEnvironment guard("ARCADIA_SOURCE_ROOT", "source"); + EXPECT_EQ("source", GetEnv("ARCADIA_SOURCE_ROOT")); + } + EXPECT_EQ(before, GetEnv("ARCADIA_SOURCE_ROOT")); +} + +TEST(TScopedEnvironment, MultiValue) { + TVector<TString> before{GetEnv("ARCADIA_SOURCE_ROOT"), GetEnv("ARCADIA_BUILD_ROOT")}; + { + NTesting::TScopedEnvironment guard{{ + {"ARCADIA_SOURCE_ROOT", "source"}, + {"ARCADIA_BUILD_ROOT", "build"}, + }}; + EXPECT_EQ("source", GetEnv("ARCADIA_SOURCE_ROOT")); + EXPECT_EQ("build", GetEnv("ARCADIA_BUILD_ROOT")); + } + TVector<TString> after{GetEnv("ARCADIA_SOURCE_ROOT"), GetEnv("ARCADIA_BUILD_ROOT")}; + EXPECT_EQ(before, after); +} |