| /************************************************************************ |
| * |
| * 22.locale.stdcxx-554.cpp - the regression test for STDCXX-554 issue |
| * |
| * $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. |
| * |
| **************************************************************************/ |
| |
| #include <cstring> // for memset() |
| #include <cassert> // for assert() |
| |
| #include <locale> // for std::moneypunct, std::messages |
| |
| template <class charT> |
| void test_moneypunct (charT) |
| { |
| typedef std::moneypunct <charT> PunctT; |
| |
| const char fill = '\xdc'; |
| |
| char buf [sizeof (PunctT) + 1]; |
| std::memset (buf, fill, sizeof (buf)); |
| |
| PunctT* p = new (buf) PunctT (); |
| |
| assert (fill == buf [sizeof (PunctT)]); |
| |
| p->~PunctT (); |
| } |
| |
| template <class charT> |
| void test_messages (charT) |
| { |
| typedef std::messages <charT> MessagesT; |
| |
| const char fill = '\xdc'; |
| |
| char buf [sizeof (MessagesT) + 1]; |
| std::memset (buf, fill, sizeof (buf)); |
| |
| MessagesT* p = new (buf) MessagesT (); |
| |
| assert (fill == buf [sizeof (MessagesT)]); |
| |
| p->~MessagesT (); |
| } |
| |
| int main (int, char* []) |
| { |
| test_moneypunct (char ()); |
| test_messages (char ()); |
| |
| #ifndef _RWSTD_NO_WCHAR_T |
| test_moneypunct (wchar_t ()); |
| test_messages (wchar_t ()); |
| #endif |
| |
| return 0; |
| } |