#include "catch2/catch.hpp"
#include "cetlib/getenv.h"
#include "cetlib_except/exception.h"
#include "cetlib_except/exception_category_matcher.h"
#include "cetlib_except/exception_message_matcher.h"
#include <cstdlib>
#include <string>
Go to the source code of this file.
#define _POSIX_C_SOURCE 200112L |
TEST_CASE |
( |
"getenv_value" |
| ) |
|
Definition at line 20 of file getenv_test.cc.
23 setenv(VAR,
val.c_str(), 1);
25 SECTION(
"NoThrow") { REQUIRE(
val ==
cet::getenv(VAR, std::nothrow)); }
std::string getenv(std::string const &name)
TEST_CASE |
( |
"getenv_empty" |
| ) |
|
Definition at line 28 of file getenv_test.cc.
31 setenv(VAR, val.c_str(), 1);
32 SECTION(
"Throw") { REQUIRE(val ==
cet::getenv(VAR)); }
33 SECTION(
"NoThrow") { REQUIRE(val ==
cet::getenv(VAR, std::nothrow)); }
std::string getenv(std::string const &name)
TEST_CASE |
( |
"getenv_unset" |
| ) |
|
Definition at line 36 of file getenv_test.cc.
43 REQUIRE_THROWS_MATCHES(
46 cet::exception_category_matcher(
"getenv") &&
47 cet::exception_message_matcher(Catch::Matchers::Contains(
48 "Can't find an environment variable named \""s + VAR +
"\"\n")));
std::string getenv(std::string const &name)
cet::coded_exception< error, detail::translate > exception
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.