1 // 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // 19.1 Exception classes
25 #include <testsuite_hooks.h>
30 bool test
__attribute__((unused
)) = true;
31 std::string
s("lack of sunlight, no water error");
34 std::logic_error obj
= std::logic_error(s
);
37 // std::logic_error obj((std::string)strlit);
39 VERIFY( std::strcmp(obj
.what(), s
.data()) == 0 );
44 bool test
__attribute__((unused
)) = true;
45 std::string
s("lack of sunlight error");
46 std::domain_error
x(s
);
48 VERIFY( std::strcmp(x
.what(), s
.data()) == 0 );
52 class fuzzy_logic
: public std::logic_error
55 fuzzy_logic() : std::logic_error("whoa") { }
60 bool test
__attribute__((unused
)) = true;
62 { throw fuzzy_logic(); }
63 catch(const fuzzy_logic
& obj
)
64 { VERIFY( std::strcmp("whoa", obj
.what()) == 0 ); }
69 // test copy ctors and assignment operators
71 // via Greg Bumgardner <bumgard@roguewave.com>
72 void allocate_on_stack(void)
74 const size_t num
= 512;
75 __extension__
char array
[num
];
76 for (size_t i
= 0; i
< num
; i
++)
81 bool test
__attribute__((unused
)) = true;
82 const std::string
s("CA ISO emergency once again:immediate power down");
83 const char* strlit1
= "wish I lived in Palo Alto";
84 const char* strlit2
= "...or Santa Barbara";
85 std::runtime_error
obj1(s
);
89 const std::string
s2(strlit1
);
90 std::runtime_error
obj2(s2
);
94 VERIFY( std::strcmp(strlit1
, obj1
.what()) == 0 );
98 const std::string
s3(strlit2
);
99 std::runtime_error obj3
= std::runtime_error(s3
);
103 VERIFY( std::strcmp(strlit2
, obj1
.what()) == 0 );