Remove building with NOCRYPTO option
[minix3.git] / external / bsd / atf / dist / tools / env_test.cpp
blob441a16ff89523d52c7ee650e3d727af11a438755
1 //
2 // Automated Testing Framework (atf)
3 //
4 // Copyright (c) 2007 The NetBSD Foundation, Inc.
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
16 // THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 // CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 // IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <atf-c++.hpp>
32 #include "env.hpp"
34 // ------------------------------------------------------------------------
35 // Test cases for the free functions.
36 // ------------------------------------------------------------------------
38 ATF_TEST_CASE(has_get);
39 ATF_TEST_CASE_HEAD(has_get)
41 set_md_var("descr", "Tests the has and get functions");
43 ATF_TEST_CASE_BODY(has_get)
45 ATF_REQUIRE(tools::env::has("PATH"));
46 ATF_REQUIRE(!tools::env::get("PATH").empty());
48 ATF_REQUIRE(!tools::env::has("_UNDEFINED_VARIABLE_"));
51 ATF_TEST_CASE(set);
52 ATF_TEST_CASE_HEAD(set)
54 set_md_var("descr", "Tests the set function");
56 ATF_TEST_CASE_BODY(set)
58 ATF_REQUIRE(tools::env::has("PATH"));
59 const std::string& oldval = tools::env::get("PATH");
60 tools::env::set("PATH", "foo-bar");
61 ATF_REQUIRE(tools::env::get("PATH") != oldval);
62 ATF_REQUIRE_EQ(tools::env::get("PATH"), "foo-bar");
64 ATF_REQUIRE(!tools::env::has("_UNDEFINED_VARIABLE_"));
65 tools::env::set("_UNDEFINED_VARIABLE_", "foo2-bar2");
66 ATF_REQUIRE_EQ(tools::env::get("_UNDEFINED_VARIABLE_"), "foo2-bar2");
69 ATF_TEST_CASE(unset);
70 ATF_TEST_CASE_HEAD(unset)
72 set_md_var("descr", "Tests the unset function");
74 ATF_TEST_CASE_BODY(unset)
76 ATF_REQUIRE(tools::env::has("PATH"));
77 tools::env::unset("PATH");
78 ATF_REQUIRE(!tools::env::has("PATH"));
81 // ------------------------------------------------------------------------
82 // Main.
83 // ------------------------------------------------------------------------
85 ATF_INIT_TEST_CASES(tcs)
87 // Add the test cases for the free functions.
88 ATF_ADD_TEST_CASE(tcs, has_get);
89 ATF_ADD_TEST_CASE(tcs, set);
90 ATF_ADD_TEST_CASE(tcs, unset);