Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Data Structures | Macros | Functions
19.std.exceptions.cpp File Reference
#include <stdexcept>
#include <string>
#include <rw_new.h>
#include <rw_driver.h>
#include <cstddef>
Include dependency graph for 19.std.exceptions.cpp:

Go to the source code of this file.

Data Structures

struct  bogus_exception
 

Macros

#define TEST_NAMESPACE_DEF(T)   void T ()
 
#define _PTR_THROWS(spec)   _THROWS (spec)
 
#define TEST_DEF(T)
 
#define TEST_EX_SPEC(T)
 

Functions

template<class Exception >
int test_ex_spec (Exception *, const char *str)
 
void is_explicit (const std::logic_error &)
 
void is_explicit (const std::domain_error &)
 
void is_explicit (const std::invalid_argument &)
 
void is_explicit (const std::length_error &)
 
void is_explicit (const std::out_of_range &)
 
void is_explicit (const std::runtime_error &)
 
void is_explicit (const std::range_error &)
 
void is_explicit (const std::overflow_error &)
 
void is_explicit (const std::underflow_error &)
 
void is_explicit (const bogus_exception &)
 
int cmp (const char *s1, const char *s2)
 
template<class Exception >
int test_throw (Exception *, const char *str)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ _PTR_THROWS

#define _PTR_THROWS (   spec)    _THROWS (spec)

Definition at line 103 of file 19.std.exceptions.cpp.

◆ TEST_DEF

#define TEST_DEF (   T)
Value:
typedef std::T T ## _type; \
TEST_NAMESPACE_DEF (T); \
/* construct an object */ \
std::T obj_ ## T ("std::" _RWSTD_STR (T)); \
/* assign the address of object to std::exception* */ \
e = &obj_ ## T; \
/* verify that assignment can't throw */ \
std::T& (std::T::*p_assign_ ## T)(const std::T&) \
_PTR_THROWS(()) = &std::T::operator=; \
_RWSTD_UNUSED (p_assign_ ## T); \
/* verify that what() can't throw */ \
const char* (std::T::*p_what_ ## T)() const \
_PTR_THROWS(()) = &std::T::what; \
_RWSTD_UNUSED (p_what_ ## T); \
/* verify ctor postcondition */ \
result = result << 1 | cmp (obj_ ## T.what (), \
"std::" _RWSTD_STR (T))
#define T
Definition 17.names.cpp:163
#define e
Definition 17.names.cpp:118
#define _PTR_THROWS(spec)
#define _RWSTD_UNUSED(arg)
Definition _defs.h:972
#define _RWSTD_STR(x)
Definition _defs.h:1116
Definition json.h:5363

Definition at line 112 of file 19.std.exceptions.cpp.

◆ TEST_EX_SPEC

#define TEST_EX_SPEC (   T)
Value:
do { \
/* do not induce an exception from replacement operator new */ \
*pst->throw_at_calls_ [0] = std::size_t (-1); \
*pst->throw_at_calls_ [1] = std::size_t (-1); \
/* verify that exception objects can be thrown, caught, and rethrown */\
test_throw ((std:: T*)0, "std::" #T); \
/* induce an exception from replacement operator new */ \
*pst->throw_at_calls_ [0] = pst->new_calls_ [0] + 1; \
*pst->throw_at_calls_ [1] = pst->new_calls_ [1] + 1; \
/* verify that each exception ctor propagates the exception thrown */ \
/* from operator new(); failure wil cause a call to terminate() */ \
/* tests are expected to silently fail if (0 == new_throws) holds */ \
const int threw = test_ex_spec ((std::T*)0, long_str); \
rw_assert (threw == new_throws, 0, __LINE__, \
"attempthing to construct a std::" #T " %s an exception", \
new_throws ? "failed to rethrow" : "unexpectedly threw"); \
} while (0)
int test_ex_spec(Exception *, const char *str)

◆ TEST_NAMESPACE_DEF

#define TEST_NAMESPACE_DEF (   T)    void T ()

Definition at line 96 of file 19.std.exceptions.cpp.

Function Documentation

◆ cmp()

int cmp ( const char *  s1,
const char *  s2 
)

Definition at line 132 of file 19.std.exceptions.cpp.

◆ is_explicit() [1/10]

void is_explicit ( const bogus_exception &  )

Definition at line 88 of file 19.std.exceptions.cpp.

◆ is_explicit() [2/10]

void is_explicit ( const std::domain_error &  )

◆ is_explicit() [3/10]

void is_explicit ( const std::invalid_argument &  )

◆ is_explicit() [4/10]

void is_explicit ( const std::length_error &  )

◆ is_explicit() [5/10]

void is_explicit ( const std::logic_error &  )

◆ is_explicit() [6/10]

void is_explicit ( const std::out_of_range &  )

◆ is_explicit() [7/10]

void is_explicit ( const std::overflow_error &  )

◆ is_explicit() [8/10]

void is_explicit ( const std::range_error &  )

◆ is_explicit() [9/10]

void is_explicit ( const std::runtime_error &  )

◆ is_explicit() [10/10]

void is_explicit ( const std::underflow_error &  )

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 464 of file 19.std.exceptions.cpp.

◆ test_ex_spec()

template<class Exception >
int test_ex_spec ( Exception *  ,
const char *  str 
)

19.std.exceptions.cpp - test exercising [lib.std.exceptions]

$Id$

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2001-2008 Rogue Wave Software.

Definition at line 35 of file 19.std.exceptions.cpp.

◆ test_throw()

template<class Exception >
int test_throw ( Exception *  ,
const char *  str 
)

Definition at line 186 of file 19.std.exceptions.cpp.