Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal/catch_getenv.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-10-22 13:00:31 +0200
committerMartin Hořeňovský2022-10-22 22:18:24 +0200
commit3fed2307e756aae3d2908ac71032aa7158a6cbfb (patch)
treef340b97c4c6b66f4a8277775ee2b8b4fbd030c55 /src/catch2/internal/catch_getenv.cpp
parent2d0dcc36e8202504f870a79820ab7d4bb39cf410 (diff)
downloadcatch3-3fed2307e756aae3d2908ac71032aa7158a6cbfb.tar.gz
Add Detail::getEnv wrapper that compiles under UWP
Under UWP it will always return nullptr, so UWP will essentially behave as if the environment was just empty.
Diffstat (limited to 'src/catch2/internal/catch_getenv.cpp')
-rw-r--r--src/catch2/internal/catch_getenv.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/catch2/internal/catch_getenv.cpp b/src/catch2/internal/catch_getenv.cpp
new file mode 100644
index 00000000..e9be6372
--- /dev/null
+++ b/src/catch2/internal/catch_getenv.cpp
@@ -0,0 +1,36 @@
+
+// Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+
+#include <catch2/internal/catch_getenv.hpp>
+#include <catch2/internal/catch_platform.hpp>
+
+#include <cstdlib>
+
+namespace Catch {
+ namespace Detail {
+
+#if defined( CATCH_PLATFORM_WINDOWS_UWP )
+ char const* getEnv( char const* ) { return nullptr; }
+#else
+
+ char const* getEnv( char const* varName ) {
+# if defined( _MSC_VER )
+# pragma warning( push )
+# pragma warning( disable : 4996 ) // use getenv_s instead of getenv
+# endif
+
+ return std::getenv( varName );
+
+# if defined( _MSC_VER )
+# pragma warning( pop )
+# endif
+#endif
+ }
+
+} // namespace Detail
+} // namespace Catch