[AMDGPU] Mark AGPR tuple implicit in the first instr of AGPR spills. (#115285)
[llvm-project.git] / libc / test / integration / src / stdlib / getenv_test.cpp
blob82a9b89533d2eb5ccfb83223ad7abd5c3396f569
1 //===-- Unittests for getenv ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/stdlib/getenv.h"
11 #include "test/IntegrationTest/test.h"
13 static bool my_streq(const char *lhs, const char *rhs) {
14 if (lhs == rhs)
15 return true;
16 if (((lhs == static_cast<char *>(nullptr)) &&
17 (rhs != static_cast<char *>(nullptr))) ||
18 ((lhs != static_cast<char *>(nullptr)) &&
19 (rhs == static_cast<char *>(nullptr)))) {
20 return false;
22 const char *l, *r;
23 for (l = lhs, r = rhs; *l != '\0' && *r != '\0'; ++l, ++r)
24 if (*l != *r)
25 return false;
27 return *l == '\0' && *r == '\0';
30 TEST_MAIN(int argc, char **argv, char **envp) {
31 ASSERT_TRUE(
32 my_streq(LIBC_NAMESPACE::getenv(""), static_cast<char *>(nullptr)));
33 ASSERT_TRUE(
34 my_streq(LIBC_NAMESPACE::getenv("="), static_cast<char *>(nullptr)));
35 ASSERT_TRUE(my_streq(LIBC_NAMESPACE::getenv("MISSING ENV VARIABLE"),
36 static_cast<char *>(nullptr)));
37 ASSERT_FALSE(
38 my_streq(LIBC_NAMESPACE::getenv("PATH"), static_cast<char *>(nullptr)));
39 ASSERT_TRUE(my_streq(LIBC_NAMESPACE::getenv("FRANCE"), "Paris"));
40 ASSERT_FALSE(my_streq(LIBC_NAMESPACE::getenv("FRANCE"), "Berlin"));
41 ASSERT_TRUE(my_streq(LIBC_NAMESPACE::getenv("GERMANY"), "Berlin"));
42 ASSERT_TRUE(
43 my_streq(LIBC_NAMESPACE::getenv("FRANC"), static_cast<char *>(nullptr)));
44 ASSERT_TRUE(my_streq(LIBC_NAMESPACE::getenv("FRANCE1"),
45 static_cast<char *>(nullptr)));
47 return 0;