~ubuntu-branches/ubuntu/wily/davix/wily

« back to all changes in this revision

Viewing changes to deps/boost_intern/src/system/test/system_error_test.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2015-07-31 13:17:55 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20150731131755-mizprbmn7ogv33te
Tags: 0.4.1-1
* Update to version 0.4.1
* Implement Multi-Arch support

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  system_error_test.cpp  ---------------------------------------------------//
2
 
 
3
 
//  Copyright Beman Dawes 2006
4
 
 
5
 
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
6
 
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
 
 
8
 
//  See library home page at http://www.boost.org/libs/system
9
 
 
10
 
//----------------------------------------------------------------------------// 
11
 
 
12
 
//  test without deprecated features
13
 
#define BOOST_SYSTEM_NO_DEPRECATED
14
 
 
15
 
#include <boost/config/warning_disable.hpp>
16
 
 
17
 
#include <boost/detail/lightweight_test.hpp>
18
 
#include <boost/system/system_error.hpp>
19
 
#include <iostream>
20
 
#include <string>
21
 
 
22
 
#ifdef BOOST_WINDOWS_API
23
 
#include <windows.h>
24
 
#endif
25
 
 
26
 
using boost::system::system_error;
27
 
using boost::system::error_code;
28
 
using boost::system::system_category;
29
 
using std::string;
30
 
 
31
 
#define TEST(x,v,w) test(#x,x,v,w)
32
 
 
33
 
namespace
34
 
{
35
 
  void test( const char * desc, const system_error & ex,
36
 
    int v, const char * str )
37
 
  {
38
 
    std::cout << "test " << desc << "\n what() returns \"" << ex.what() << "\"\n";
39
 
    BOOST_TEST( ex.code().value() == v );
40
 
    BOOST_TEST( ex.code().category() == system_category() );
41
 
# ifdef BOOST_WINDOWS_API
42
 
    LANGID language_id;
43
 
#   if !defined(__MINGW32__) && !defined(__CYGWIN__)
44
 
      language_id = ::GetUserDefaultUILanguage();
45
 
#   else
46
 
      language_id = 0x0409; // Assume US English
47
 
#   endif
48
 
    // std::cout << "GetUserDefaultUILanguage() returns " << language_id << '\n';
49
 
    if ( language_id == 0x0409 )  // English (United States)
50
 
    {
51
 
      BOOST_TEST( std::string( ex.what() ) == str );
52
 
      if ( std::string( ex.what() ) != str )
53
 
        std::cout << "expected \"" << str << "\", but what() returned \""
54
 
          << ex.what() << "\"\n";
55
 
    }
56
 
# endif
57
 
  }
58
 
 
59
 
  const boost::uint_least32_t uvalue = 2u;
60
 
}
61
 
 
62
 
int main( int, char *[] )
63
 
{
64
 
  // all constructors, in the same order as they appear in the header:
65
 
 
66
 
  system_error c1_0( error_code(0, system_category()) ); 
67
 
  system_error c1_1( error_code(1, system_category()) );
68
 
  system_error c1_2u( error_code(uvalue, system_category()) );
69
 
 
70
 
  system_error c2_0( error_code(0, system_category()), string("c2_0") ); 
71
 
  system_error c2_1( error_code(1, system_category()), string("c2_1") );
72
 
 
73
 
  system_error c3_0( error_code(0, system_category()), "c3_0" ); 
74
 
  system_error c3_1( error_code(1, system_category()), "c3_1" );
75
 
 
76
 
  system_error c4_0( 0, system_category() ); 
77
 
  system_error c4_1( 1, system_category() );
78
 
  system_error c4_2u( uvalue, system_category() );
79
 
 
80
 
  system_error c5_0( 0, system_category(), string("c5_0") ); 
81
 
  system_error c5_1( 1, system_category(), string("c5_1") );
82
 
 
83
 
  system_error c6_0( 0, system_category(), "c6_0" ); 
84
 
  system_error c6_1( 1, system_category(), "c6_1" );
85
 
 
86
 
  TEST( c1_0, 0, "The operation completed successfully" );
87
 
  TEST( c1_1, 1, "Incorrect function" );
88
 
  TEST( c1_2u, 2, "The system cannot find the file specified" );
89
 
 
90
 
  TEST( c2_0, 0, "c2_0: The operation completed successfully" );
91
 
  TEST( c2_1, 1, "c2_1: Incorrect function" );
92
 
 
93
 
  TEST( c3_0, 0, "c3_0: The operation completed successfully" );
94
 
  TEST( c3_1, 1, "c3_1: Incorrect function" );
95
 
 
96
 
  TEST( c4_0, 0, "The operation completed successfully" );
97
 
  TEST( c4_1, 1, "Incorrect function" );
98
 
  TEST( c4_2u, 2, "The system cannot find the file specified" );
99
 
 
100
 
  TEST( c5_0, 0, "c5_0: The operation completed successfully" );
101
 
  TEST( c5_1, 1, "c5_1: Incorrect function" );
102
 
 
103
 
  TEST( c6_0, 0, "c6_0: The operation completed successfully" );
104
 
  TEST( c6_1, 1, "c6_1: Incorrect function" );
105
 
 
106
 
  return ::boost::report_errors();
107
 
}
108
 
 
109