Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 20128 invoked from network); 18 Apr 2008 15:12:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Apr 2008 15:12:27 -0000 Received: (qmail 26071 invoked by uid 500); 18 Apr 2008 15:12:28 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 26057 invoked by uid 500); 18 Apr 2008 15:12:28 -0000 Mailing-List: contact commits-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list commits@stdcxx.apache.org Received: (qmail 26048 invoked by uid 99); 18 Apr 2008 15:12:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 08:12:28 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 15:11:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F092B1A9832; Fri, 18 Apr 2008 08:12:03 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r649564 - /stdcxx/trunk/tests/localization/22.locale.ctype.widen.cpp Date: Fri, 18 Apr 2008 15:12:03 -0000 To: commits@stdcxx.apache.org From: elemings@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080418151203.F092B1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elemings Date: Fri Apr 18 08:12:00 2008 New Revision: 649564 URL: http://svn.apache.org/viewvc?rev=649564&view=rev Log: 2008-04-18 Eric Lemings STDCXX-866 * tests/localization/22.locale.ctype.widen.cpp: Migrated new test from old Perforce repository. Added: stdcxx/trunk/tests/localization/22.locale.ctype.widen.cpp Added: stdcxx/trunk/tests/localization/22.locale.ctype.widen.cpp URL: http://svn.apache.org/viewvc/stdcxx/trunk/tests/localization/22.locale.ctype.widen.cpp?rev=649564&view=auto ============================================================================== --- stdcxx/trunk/tests/localization/22.locale.ctype.widen.cpp (added) +++ stdcxx/trunk/tests/localization/22.locale.ctype.widen.cpp Fri Apr 18 08:12:00 2008 @@ -0,0 +1,152 @@ +/*************************************************************************** + * + * 22.locale.ctype.widen.cpp - tests exercising std::ctype::widen() + * + * $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. + * + * Copyright 1994-2008 Rogue Wave Software. + * + **************************************************************************/ + +#include + +#include + +typedef unsigned char UChar; + +#ifndef _RWSTD_NO_WCHAR_T + +typedef std::ctype WCtype; + +#endif // _RWSTD_NO_WCHAR_T + +/**************************************************************************/ + +static void +test_char () +{ + rw_info (0, __FILE__, __LINE__, "std::ctype::widen(char)"); + + const std::locale loc; + + const WCtype& ctp = std::use_facet (loc); + + for (int i = 0; i != int (_RWSTD_UCHAR_MAX) + 1; ++i) { + + // compute the argument, and the expected and actual results + const char narrow = char (i); + const char expect = narrow; + const char wide = ctp.widen (narrow); + + rw_assert (expect == wide, __FILE__, __LINE__, + "std::ctype::widen(%#c) == %#c, got %#c", + narrow, expect, wide); + } +} + +/**************************************************************************/ + +// will leave this here for now since it appears to be a placeholder +// for further testing + +static void +test_byname_char () +{ + rw_info (0, __FILE__, __LINE__, + "std::ctype_byname::widen(char)"); + + rw_warn (false, __FILE__, __LINE__, + "ctype_byname::widen() not exercised"); +} + +/**************************************************************************/ + +static void +test_wchar_t () +{ + rw_info (0, __FILE__, __LINE__, + "std::ctype::widen(char)"); + +#ifndef _RWSTD_NO_WCHAR_T + + const std::locale loc; + + const WCtype& ctp = std::use_facet (loc); + + for (int i = 0; i != int (_RWSTD_UCHAR_MAX) + 1; ++i) { + + // compute the argument, and the expected and actual results + const char narrow = char (i); + const wchar_t expect = wchar_t (UChar (narrow)); + const wchar_t wide = ctp.widen (narrow); + + rw_assert (expect == wide, __FILE__, __LINE__, + "std::ctype::widen(%#c) == %#Lc, got %#Lc", + narrow, expect, wide); + } + +#else // if defined (_RWSTD_NO_WCHAR_T) + + rw_warn (false, __FILE__, __LINE__, + "ctype::widen() not exercised: " + "macro _RWSTD_NO_WCHAR_T defined"); + +#endif // _RWSTD_NO_WCHAR_T + +} + +/**************************************************************************/ + +// another placeholder for further testing? + +static void +test_byname_wchar_t () +{ + rw_info (0, __FILE__, __LINE__, + "std::ctype_byname::widen(char)"); + + rw_warn (false, __FILE__, __LINE__, + "ctype_byname::widen() not exercised"); +} + +/**************************************************************************/ + +static int +run_test (int /*unused*/, char* /*unused*/ []) +{ + test_char (); + test_byname_char (); + + test_wchar_t (); + test_byname_wchar_t (); + + return 0; +} + +/*extern*/ int +main (int argc, char* argv []) +{ + return rw_test (argc, argv, __FILE__, + "lib.locale.ctype.widen", + 0, // no comment + run_test, "", 0); +} +