mirror of
https://github.com/boostorg/nowide.git
synced 2026-02-22 15:32:35 +00:00
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
//
|
|
// 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)
|
|
//
|
|
|
|
#ifdef _MSC_VER
|
|
# define _CRT_SECURE_NO_WARNINGS
|
|
#endif
|
|
|
|
#include <boost/nowide/cenv.hpp>
|
|
#include <boost/core/lightweight_test.hpp>
|
|
#include <iostream>
|
|
|
|
#if defined(BOOST_NOWIDE_TEST_INCLUDE_WINDOWS) && defined(BOOST_WINDOWS)
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
#define TEST BOOST_TEST
|
|
|
|
int main()
|
|
{
|
|
try {
|
|
std::string example = "\xd7\xa9-\xd0\xbc-\xce\xbd";
|
|
char penv[256] = {0};
|
|
strncpy(penv,("BOOST_TEST2=" + example + "x").c_str(),sizeof(penv)-1);
|
|
|
|
TEST(boost::nowide::setenv("BOOST_TEST1",example.c_str(),1)==0);
|
|
TEST(boost::nowide::getenv("BOOST_TEST1"));
|
|
TEST(boost::nowide::getenv("BOOST_TEST1")==example);
|
|
TEST(boost::nowide::setenv("BOOST_TEST1","xx",0)==0);
|
|
TEST(boost::nowide::getenv("BOOST_TEST1")==example);
|
|
TEST(boost::nowide::putenv(penv)==0);
|
|
TEST(boost::nowide::getenv("BOOST_TEST2"));
|
|
TEST(boost::nowide::getenv("BOOST_TEST_INVALID")==0);
|
|
TEST(boost::nowide::getenv("BOOST_TEST2")==example + "x");
|
|
}
|
|
catch(std::exception const &e) {
|
|
std::cerr << "Failed " << e.what() << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
return boost::report_errors();
|
|
}
|
|
|
|
///
|
|
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
|