mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-28 08:02:08 +00:00
[libcxx][test] Portability fix for some locale-dependent tests.
Tests for `std::system_error` constructor marked as slightly non-portable. One (but not the only one) reason for such non-portability is that these tests assume the default locale to be set to "C" (or "POSIX"). However, the default locale for the process depends on OS and environment. This patch adds explicit setting of the correct locale expected by the tests. Thanks to Andrey Maksimov for the patch. Differential Revision: https://reviews.llvm.org/D72456
This commit is contained in:
parent
645bba8d3d
commit
9f19cc8cac
@ -17,11 +17,13 @@
|
||||
#include <system_error>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <clocale>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
std::setlocale (LC_ALL, "C");
|
||||
std::system_error se(static_cast<int>(std::errc::not_a_directory),
|
||||
std::generic_category(), "some text");
|
||||
assert(se.code() == std::make_error_code(std::errc::not_a_directory));
|
||||
|
@ -17,11 +17,13 @@
|
||||
#include <system_error>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <clocale>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
std::setlocale (LC_ALL, "C");
|
||||
std::string what_arg("test message");
|
||||
std::system_error se(make_error_code(std::errc::not_a_directory), what_arg.c_str());
|
||||
assert(se.code() == std::make_error_code(std::errc::not_a_directory));
|
||||
|
@ -17,11 +17,13 @@
|
||||
#include <system_error>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <clocale>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
std::setlocale (LC_ALL, "C");
|
||||
std::string what_arg("test message");
|
||||
std::system_error se(make_error_code(std::errc::not_a_directory), what_arg);
|
||||
assert(se.code() == std::make_error_code(std::errc::not_a_directory));
|
||||
|
@ -17,11 +17,13 @@
|
||||
#include <system_error>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <clocale>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
std::setlocale (LC_ALL, "C");
|
||||
std::system_error se(static_cast<int>(std::errc::not_a_directory),
|
||||
std::generic_category());
|
||||
assert(se.code() == std::make_error_code(std::errc::not_a_directory));
|
||||
|
@ -17,11 +17,13 @@
|
||||
#include <system_error>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <clocale>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
std::setlocale (LC_ALL, "C");
|
||||
std::string what_arg("test message");
|
||||
std::system_error se(static_cast<int>(std::errc::not_a_directory),
|
||||
std::generic_category(), what_arg.c_str());
|
||||
|
@ -17,11 +17,13 @@
|
||||
#include <system_error>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <clocale>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
std::setlocale (LC_ALL, "C");
|
||||
std::string what_arg("test message");
|
||||
std::system_error se(static_cast<int>(std::errc::not_a_directory),
|
||||
std::generic_category(), what_arg);
|
||||
|
Loading…
Reference in New Issue
Block a user