From commits-return-3091-apmail-stdcxx-commits-archive=stdcxx.apache.org@stdcxx.apache.org Fri Jun 13 20:23:33 2008 Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 36406 invoked from network); 13 Jun 2008 20:23:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jun 2008 20:23:33 -0000 Received: (qmail 3109 invoked by uid 500); 13 Jun 2008 20:23:35 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 3090 invoked by uid 500); 13 Jun 2008 20:23:35 -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 3081 invoked by uid 99); 13 Jun 2008 20:23:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2008 13:23:35 -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.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2008 20:22:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6E68F2388A0A; Fri, 13 Jun 2008 13:23:12 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r667638 - /stdcxx/branches/4.3.x/tests/utilities/20.forward.cpp Date: Fri, 13 Jun 2008 20:23:12 -0000 To: commits@stdcxx.apache.org From: elemings@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080613202312.6E68F2388A0A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elemings Date: Fri Jun 13 13:23:12 2008 New Revision: 667638 URL: http://svn.apache.org/viewvc?rev=667638&view=rev Log: 2008-06-13 Eric Lemings STDCXX-958 * tests/utilities/20.forward.cpp: Rough outline of new test for exercising move/forward helpers in header. Added: stdcxx/branches/4.3.x/tests/utilities/20.forward.cpp Added: stdcxx/branches/4.3.x/tests/utilities/20.forward.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utilities/20.forward.cpp?rev=667638&view=auto ============================================================================== --- stdcxx/branches/4.3.x/tests/utilities/20.forward.cpp (added) +++ stdcxx/branches/4.3.x/tests/utilities/20.forward.cpp Fri Jun 13 13:23:12 2008 @@ -0,0 +1,126 @@ +/*************************************************************************** + * + * 20.forward.cpp - tests exercising move/forward helpers + * + * $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 +#include + +#include + + +struct Foo +{ + Foo (int& ) { } +}; + +// compile tests + +typedef std::identity FooIdent; +typedef std::identity::type FooIdentType; + +_RWSTD_STATIC_ASSERT ((_RW::__rw_is_same::value), + "(is_same), got false, " + "expected true"); + +static void +test_identity () +{ + rw_info (0, __FILE__, __LINE__, "std::identity class template"); + + int i = 1; + FooIdent foo_ident; + Foo foo = foo_ident (i); + +} + +/**************************************************************************/ + +// using example from standard as a test case + +template +class shared_ptr +{ + Type* ptr_; + +public: + shared_ptr (Type* ptr): ptr_ (ptr) { } + ~shared_ptr () { delete ptr_; } +}; + +template +shared_ptr factory (AType&& at) +{ + return shared_ptr (new Type (std::forward (at))); +}; + +static void +test_forward () +{ + rw_info (0, __FILE__, __LINE__, "std::forward() function"); + +} + +/**************************************************************************/ + +static void +test_move () +{ + rw_info (0, __FILE__, __LINE__, "std::move() function"); + +} + +/**************************************************************************/ + +static int +run_test (int /*unused*/, char* /*unused*/ []) +{ + +#if !defined _RWSTD_NO_RVALUE_REFERENCES + + test_identity (); + test_forward (); + test_move (); + +#else // no rvalue references + + rw_info (true, __FILE__, __LINE__, + "No compiler support for rvalue references; tests disabled."); + +#endif // !defined _RWSTD_NO_RVALUE_REFERENCES + + return 0; +} + +/*extern*/ int +main (int argc, char* argv []) +{ + return rw_test (argc, argv, __FILE__, + "[forward]", "20.2.2 forward/move helpers", + run_test, "", 0); +} +