codecvt_utf8.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <codecvt>
11
12// template <class Elem, unsigned long Maxcode = 0x10ffff,
13//           codecvt_mode Mode = (codecvt_mode)0>
14// class codecvt_utf8
15//     : public codecvt<Elem, char, mbstate_t>
16// {
17//     // unspecified
18// };
19
20// Not a portable test
21
22#include <codecvt>
23#include <cassert>
24
25int outstanding_news = 0;
26
27void* operator new(std::size_t s) throw(std::bad_alloc)
28{
29    ++outstanding_news;
30    return std::malloc(s);
31}
32
33void  operator delete(void* p) throw()
34{
35    if (p)
36    {
37        --outstanding_news;
38        std::free(p);
39    }
40}
41
42int main()
43{
44    assert(outstanding_news == 0);
45    {
46        typedef std::codecvt_utf8<wchar_t> C;
47        C c;
48        assert(outstanding_news == 0);
49    }
50    {
51        typedef std::codecvt_utf8<wchar_t> C;
52        std::locale loc(std::locale::classic(), new C);
53        assert(outstanding_news != 0);
54    }
55    assert(outstanding_news == 0);
56}
57