From c54ff48ac3abb62a40eb1a438da8e3e7ef139797 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sat, 28 Jun 2025 20:40:25 +0100 Subject: posix: add tempfile() --- nihil.posix/test_getenv.cc | 49 ---------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 nihil.posix/test_getenv.cc (limited to 'nihil.posix/test_getenv.cc') diff --git a/nihil.posix/test_getenv.cc b/nihil.posix/test_getenv.cc deleted file mode 100644 index fdb5277..0000000 --- a/nihil.posix/test_getenv.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This source code is released into the public domain. - */ - -#include -#include -#include - -#include - -#include - -import nihil.posix; - -TEST_CASE("getenv: existing value", "[getenv]") -{ - auto constexpr *name = "NIHIL_TEST_VAR"; - auto constexpr *value = "test is a test"; - - REQUIRE(::setenv(name, value, 1) == 0); - - auto const s = nihil::getenv(name); - REQUIRE(s); - REQUIRE(*s == value); -} - -TEST_CASE("getenv: non-existing value", "[getenv]") -{ - auto constexpr *name = "NIHIL_TEST_VAR"; - - REQUIRE(::unsetenv(name) == 0); - - auto const s = nihil::getenv(name); - REQUIRE(!s); - REQUIRE(s.error() == std::errc::no_such_file_or_directory); -} - -// Force the call to getenv_r() to reallocate. -TEST_CASE("getenv: long value") -{ - auto constexpr *name = "NIHIL_TEST_VAR"; - auto const value = std::string(4096, 'a'); - - REQUIRE(::setenv(name, value.c_str(), 1) == 0); - - auto const s = nihil::getenv(name); - REQUIRE(s); - REQUIRE(*s == value); -} -- cgit v1.2.3