diff options
| author | bulatman <[email protected]> | 2022-02-10 16:45:50 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:50 +0300 | 
| commit | 6560e4993b14d193f8c879e33a3de5e5eba6e21d (patch) | |
| tree | cfd2e2baa05c3196f2caacbb63c32e1df40bc3de /library/cpp/testing/common/scope.h | |
| parent | 7489e4682331202b9c7d863c0898eb83d7b12c2b (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/testing/common/scope.h')
| -rw-r--r-- | library/cpp/testing/common/scope.h | 78 | 
1 files changed, 39 insertions, 39 deletions
diff --git a/library/cpp/testing/common/scope.h b/library/cpp/testing/common/scope.h index a2ca0e77e4c..af12bda3c4d 100644 --- a/library/cpp/testing/common/scope.h +++ b/library/cpp/testing/common/scope.h @@ -1,39 +1,39 @@ -#pragma once - -#include <util/generic/string.h> -#include <util/generic/vector.h> -#include <util/system/env.h> - -#include <utility> - -namespace NTesting { -    // @brief Assigns new values to the given environment variables and restores old values upon destruction. -    // @note if there was no env variable with given name, it will be set to empty string upon destruction IGNIETFERRO-1486 -    struct TScopedEnvironment { -        TScopedEnvironment(const TString& name, const TString& value) -            : PreviousState{1, {name, ::GetEnv(name)}} -        { -            ::SetEnv(name, value); -        } - -        TScopedEnvironment(const TVector<std::pair<TString, TString>>& vars) -            : PreviousState(Reserve(vars.size())) -        { -            for (const auto& [k, v] : vars) { -                PreviousState.emplace_back(k, ::GetEnv(k)); -                ::SetEnv(k, v); -            } -        } - -        ~TScopedEnvironment() { -            for (const auto& [k, v] : PreviousState) { -                ::SetEnv(k, v); -            } -        } - -        TScopedEnvironment(const TScopedEnvironment&) = delete; -        TScopedEnvironment& operator=(const TScopedEnvironment&) = delete; -    private: -        TVector<std::pair<TString, TString>> PreviousState; -    }; -} +#pragma once  +  +#include <util/generic/string.h>  +#include <util/generic/vector.h>  +#include <util/system/env.h>  +  +#include <utility>  +  +namespace NTesting {  +    // @brief Assigns new values to the given environment variables and restores old values upon destruction.  +    // @note if there was no env variable with given name, it will be set to empty string upon destruction IGNIETFERRO-1486  +    struct TScopedEnvironment {  +        TScopedEnvironment(const TString& name, const TString& value)  +            : PreviousState{1, {name, ::GetEnv(name)}}  +        {  +            ::SetEnv(name, value);  +        }  +  +        TScopedEnvironment(const TVector<std::pair<TString, TString>>& vars)  +            : PreviousState(Reserve(vars.size()))  +        {  +            for (const auto& [k, v] : vars) {  +                PreviousState.emplace_back(k, ::GetEnv(k));  +                ::SetEnv(k, v);  +            }  +        }  +  +        ~TScopedEnvironment() {  +            for (const auto& [k, v] : PreviousState) {  +                ::SetEnv(k, v);  +            }  +        }  +  +        TScopedEnvironment(const TScopedEnvironment&) = delete;  +        TScopedEnvironment& operator=(const TScopedEnvironment&) = delete;  +    private:  +        TVector<std::pair<TString, TString>> PreviousState;  +    };  +}   | 
