2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libstdc++-v3 / testsuite / 22_locale / locale / cons / 12438.cc
blob70691d320e4ff1e93a616d0c46728d0b36bf41db
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.
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.
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.
19 // 22.1.1.2 locale constructors and destructors [lib.locale.cons]
21 #include <locale>
22 #include <stdexcept>
23 #include <cstdlib>
24 #include <testsuite_hooks.h>
26 class MyFacet : public std::locale::facet
28 public:
29 static std::locale::id id;
32 std::locale::id MyFacet::id;
34 // libstdc++/12438
35 void test01(int iters)
37 using namespace std;
38 bool test __attribute__((unused)) = true;
40 for (int i = 0; i < iters; ++i)
42 try
44 locale loc1 = locale::classic();
45 locale loc2 = __gnu_test::try_named_locale("");
46 VERIFY( !has_facet<MyFacet>(loc2) );
48 loc1.combine<MyFacet>(loc2);
49 VERIFY( false );
51 catch (std::runtime_error&)
57 int main(int argc, char* argv[])
59 // We leaked ~400-500 bytes/iter.
60 __gnu_test::set_memory_limits(10.0);
61 int iters = 30000;
63 if (argc > 1)
64 iters = atoi(argv[1]);
65 if (iters < 1)
66 iters = 1;
67 test01(iters);
69 return 0;