Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 19071 invoked from network); 18 Apr 2008 15:10:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Apr 2008 15:10:17 -0000 Received: (qmail 24533 invoked by uid 500); 18 Apr 2008 15:10:19 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 24522 invoked by uid 500); 18 Apr 2008 15:10:18 -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 24513 invoked by uid 99); 18 Apr 2008 15:10:18 -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:10:18 -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:09:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 866DF1A9832; Fri, 18 Apr 2008 08:09:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r649563 - /stdcxx/trunk/tests/numerics/26.valarray.transcend.cpp Date: Fri, 18 Apr 2008 15:09:54 -0000 To: commits@stdcxx.apache.org From: elemings@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080418150954.866DF1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elemings Date: Fri Apr 18 08:09:51 2008 New Revision: 649563 URL: http://svn.apache.org/viewvc?rev=649563&view=rev Log: 2008-04-18 Eric Lemings STDCXX-867 * tests/numerics/26.valarray.transcend.cpp: Migrated new test from old Perforce repository. Added: stdcxx/trunk/tests/numerics/26.valarray.transcend.cpp Added: stdcxx/trunk/tests/numerics/26.valarray.transcend.cpp URL: http://svn.apache.org/viewvc/stdcxx/trunk/tests/numerics/26.valarray.transcend.cpp?rev=649563&view=auto ============================================================================== --- stdcxx/trunk/tests/numerics/26.valarray.transcend.cpp (added) +++ stdcxx/trunk/tests/numerics/26.valarray.transcend.cpp Fri Apr 18 08:09:51 2008 @@ -0,0 +1,166 @@ +/*************************************************************************** + * + * 26.valarray.transcend.cpp - verify [lib.valarray.transcend] requirements + * + * $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. + * + **************************************************************************/ + +// disable implicit inclusion to work around a limitation in +// IBM's VisualAge 5.0.2.0 (see PR#26959) +#if defined __IBMCPP__ && !defined _RWSTD_NO_IMPLICIT_INCLUSION +# define _RWSTD_NO_IMPLICIT_INCLUSION +#endif // defined __IBMCPP__ && !defined _RWSTD_NO_IMPLICIT_INCLUSION + +#include +#include // for std::size_t +#include + +#include +#include + +/**************************************************************************/ + +template +static void +test_val (const char* tname) +{ + +#define TEST(fun) { \ + rw_info (0, __FILE__, __LINE__, "template <> std::valarray<%s> " \ + "std::" #fun " (std::valarray<%s>)", tname, tname); \ + \ + std::valarray val (10); \ + for (std::size_t i = 0; i != val.size (); ++i) \ + val [i] = T (i); \ + \ + const std::valarray result = std::fun (val); \ + \ + bool success = 10 == val.size () && val.size () == result.size (); \ + \ + for (std::size_t j = 0; success && j != result.size (); ++j) { \ + if (!rw_equal (result [j], T (std::fun (T (j))))) \ + success = false; \ + } \ + \ + rw_assert (success, __FILE__, __LINE__, \ + "template <> std::valarray<%s> std::" #fun \ + "(std::valarray<%s>)", tname, tname); \ + } (void)0 + +#define TEST_2(fun, x) { \ + if (x < 0) \ + rw_info (0, __FILE__, __LINE__, \ + "template <> std::valarray<%s> " \ + "std::" #fun " (const %s&, const std::" \ + "valarray<%s>&)", tname, tname, tname); \ + else if (x > 0) \ + rw_info (0, __FILE__, __LINE__, \ + "template <> std::valarray<%s> " \ + "std::" #fun " (const std::valarray<%s>&," \ + "const %s&)", tname, tname, tname); \ + else \ + rw_info (0, __FILE__, __LINE__, \ + "template <> std::valarray<%s> " \ + "std::" #fun " (const std::valarray<%s>&," \ + "const std::valarray<%s>&)", tname, tname, tname); \ + \ + std::valarray val (10); \ + for (std::size_t i = 0; i != val.size (); ++i) \ + val [i] = T (i); \ + \ + const std::valarray result = \ + x < 0 ? std::fun (T (x), val) \ + : x > 0 ? std::fun (val, T (x)) \ + : std::fun (val, val); \ + \ + bool success = 10 == val.size () && val.size () == result.size (); \ + \ + for (std::size_t j = 0; success && j != result.size (); ++j) { \ + T res; \ + if (x < 0) res = T (std::fun (T (x), T (j))); \ + if (x > 0) res = T (std::fun (T (j), T (x))); \ + if (!x) res = T (std::fun (T (j), T (j))); \ + if (!rw_equal (result [j], res)) \ + success = false; \ + } \ + \ + rw_assert (success, __FILE__, __LINE__, \ + "template <> std::valarray<%s> std::" #fun "(...)", \ + tname); \ + } (void)0 + + TEST (abs); + TEST (acos); + TEST (abs); + TEST (acos); + TEST (asin); + TEST (atan); + + TEST_2 (atan2, -2); + TEST_2 (atan2, +3); + TEST_2 (atan2, 0); + + TEST (cos); + TEST (cosh); + TEST (exp); + TEST (log); + TEST (log10); + + TEST_2 (pow, -4); + TEST_2 (pow, +5); + TEST_2 (pow, 0); + + TEST (sin); + TEST (sinh); + TEST (sqrt); + TEST (tan); + TEST (tanh); +} + +/**************************************************************************/ + +static int +run_test (int /*unused*/, char* /*unused*/ []) +{ + test_val ("float"); + test_val ("double"); + +#ifndef _RWSTD_NO_LONG_DOUBLE + + test_val ("long double"); + +#endif // _RWSTD_NO_LONG_DOUBLE + + return 0; +} + +/*extern*/ int +main (int argc, char* argv []) +{ + return rw_test (argc, argv, __FILE__, + "lib.valarray.transcend", + 0, // no comment + run_test, "", 0); +} +