forked from boostorg/nowide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_env.cpp
More file actions
49 lines (41 loc) · 1.35 KB
/
test_env.cpp
File metadata and controls
49 lines (41 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// Copyright (c) 2012 Artyom Beilis (Tonkikh)
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <nowide/cenv.hpp>
#include <iostream>
#include "test.hpp"
#if defined(NOWIDE_TEST_INCLUDE_WINDOWS) && defined(NOWIDE_WINDOWS)
#include <windows.h>
#endif
#ifdef NOWIDE_MSVC
# pragma warning(disable : 4996)
#endif
int main()
{
try {
std::string example = "\xd7\xa9-\xd0\xbc-\xce\xbd";
char penv[256] = {0};
strncpy(penv,("NOWIDE_TEST2=" + example + "x").c_str(),sizeof(penv)-1);
TEST(nowide::setenv("NOWIDE_TEST1",example.c_str(),1)==0);
TEST(nowide::getenv("NOWIDE_TEST1"));
TEST(nowide::getenv("NOWIDE_TEST1")==example);
TEST(nowide::setenv("NOWIDE_TEST1","xx",0)==0);
TEST(nowide::getenv("NOWIDE_TEST1")==example);
TEST(nowide::putenv(penv)==0);
TEST(nowide::getenv("NOWIDE_TEST2"));
TEST(nowide::getenv("NOWIDE_TEST_INVALID")==0);
TEST(nowide::getenv("NOWIDE_TEST2")==example + "x");
std::cout << "Ok" << std::endl;
return 0;
}
catch(std::exception const &e) {
std::cerr << "Failed " << e.what() << std::endl;
return 1;
}
}
///
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4