Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72920 - in trunk/libs/filesystem: test v3/test
From: bdawes_at_[hidden]
Date: 2011-07-05 10:26:38


Author: bemandawes
Date: 2011-07-05 10:26:37 EDT (Tue, 05 Jul 2011)
New Revision: 72920
URL: http://svn.boost.org/trac/boost/changeset/72920

Log:
Initial commit
Added:
   trunk/libs/filesystem/v3/test/locale_info.cpp (contents, props changed)
Text files modified:
   trunk/libs/filesystem/test/Jamfile.v2 | 1 +
   1 files changed, 1 insertions(+), 0 deletions(-)

Modified: trunk/libs/filesystem/test/Jamfile.v2
==============================================================================
--- trunk/libs/filesystem/test/Jamfile.v2 (original)
+++ trunk/libs/filesystem/test/Jamfile.v2 2011-07-05 10:26:37 EDT (Tue, 05 Jul 2011)
@@ -28,4 +28,5 @@
        [ run ../v3/test/deprecated_test.cpp : : : : v3_deprecated_test ]
        [ run ../v3/example/simple_ls.cpp : : : : v3_simple_ls ]
  
+ [ run ../v3/test/locale_info.cpp : : : <test-info>always_show_run_output ]
        ;

Added: trunk/libs/filesystem/v3/test/locale_info.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/filesystem/v3/test/locale_info.cpp 2011-07-05 10:26:37 EDT (Tue, 05 Jul 2011)
@@ -0,0 +1,79 @@
+// 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;
+
+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;
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk