]>
Commit | Line | Data |
---|---|---|
155f6fbb PC |
1 | // Copyright (C) 2003 Free Software Foundation |
2 | // | |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 2, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING. If not, write to the Free | |
16 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
17 | // USA. | |
18 | ||
19 | // 22.1.1.2 locale constructors and destructors [lib.locale.cons] | |
20 | ||
21 | #include <locale> | |
22 | #include <stdexcept> | |
23 | #include <cstdlib> | |
24 | #include <testsuite_hooks.h> | |
25 | ||
26 | class MyFacet : public std::locale::facet | |
27 | { | |
28 | public: | |
29 | static std::locale::id id; | |
30 | }; | |
31 | ||
32 | std::locale::id MyFacet::id; | |
33 | ||
34 | // libstdc++/12438 | |
35 | void test01(int iters) | |
36 | { | |
37 | using namespace std; | |
38 | bool test __attribute__((unused)) = true; | |
39 | ||
40 | for (int i = 0; i < iters; ++i) | |
41 | { | |
42 | try | |
43 | { | |
44 | locale loc1 = locale::classic(); | |
45 | locale loc2(""); | |
46 | VERIFY( !has_facet<MyFacet>(loc2) ); | |
47 | ||
48 | loc1.combine<MyFacet>(loc2); | |
49 | VERIFY( false ); | |
50 | } | |
51 | catch (std::runtime_error&) | |
52 | { | |
53 | } | |
54 | } | |
55 | } | |
56 | ||
57 | int main(int argc, char* argv[]) | |
58 | { | |
59 | // We leaked ~400-500 bytes/iter. | |
60 | __gnu_test::set_memory_limits(2.5); | |
61 | int iters = 10000; | |
62 | ||
63 | if (argc > 1) | |
64 | iters = atoi(argv[1]); | |
65 | if (iters < 1) | |
66 | iters = 1; | |
67 | test01(iters); | |
68 | ||
69 | return 0; | |
70 | } |