summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/filesystem/test/locale_info.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/filesystem/test/locale_info.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/filesystem/test/locale_info.cpp')
-rw-r--r--src/boost/libs/filesystem/test/locale_info.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/boost/libs/filesystem/test/locale_info.cpp b/src/boost/libs/filesystem/test/locale_info.cpp
new file mode 100644
index 00000000..db57bb15
--- /dev/null
+++ b/src/boost/libs/filesystem/test/locale_info.cpp
@@ -0,0 +1,88 @@
+// locale_info.cpp ---------------------------------------------------------//
+
+// Copyright Beman Dawes 2011
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <locale>
+#include <iostream>
+#include <exception>
+#include <cstdlib>
+using namespace std;
+
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable: 4996) // ... Function call with parameters that may be unsafe
+#endif
+
+namespace
+{
+ void facet_info(const locale& loc, const char* msg)
+ {
+ cout << "has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >("
+ << msg << ") is "
+ << (has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)
+ ? "true\n"
+ : "false\n");
+ }
+
+ void default_info()
+ {
+ try
+ {
+ locale loc;
+ cout << "\nlocale default construction OK" << endl;
+ facet_info(loc, "locale()");
+ }
+ catch (const exception& ex)
+ {
+ cout << "\nlocale default construction threw: " << ex.what() << endl;
+ }
+ }
+
+ void null_string_info()
+ {
+ try
+ {
+ locale loc("");
+ cout << "\nlocale(\"\") construction OK" << endl;
+ facet_info(loc, "locale(\"\")");
+ }
+ catch (const exception& ex)
+ {
+ cout << "\nlocale(\"\") construction threw: " << ex.what() << endl;
+ }
+ }
+
+ void classic_info()
+ {
+ try
+ {
+ locale loc(locale::classic());
+ cout << "\nlocale(locale::classic()) copy construction OK" << endl;
+ facet_info(loc, "locale::classic()");
+ }
+ catch (const exception& ex)
+ {
+ cout << "\nlocale(locale::clasic()) copy construction threw: " << ex.what() << endl;
+ }
+ }
+}
+
+int main()
+{
+ const char* lang = getenv("LANG");
+ cout << "\nLANG environmental variable is "
+ << (lang ? lang : "not present") << endl;
+
+ default_info();
+ null_string_info();
+ classic_info();
+
+ return 0;
+}
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif