You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2007/09/15 22:33:32 UTC

Re: svn commit: r575614 - /incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp

faridz@apache.org wrote:
> Author: faridz
> Date: Fri Sep 14 03:49:31 2007
> New Revision: 575614
> 
> URL: http://svn.apache.org/viewvc?rev=575614&view=rev
> Log:
> 2007-09-14 Farid Zaripov <Fa...@epam.com>
> 
> 	* 22.locale.stdcxx-554.cpp: Added a regression test for STDCXX-554.

Good job narrowing it down to a small test case!

Unless there's no easy way to write the test without involving
the driver I think we said regression tests would not depend on
it and use the assert macro instead. Since the regular unit test
exercises the same functionality and uncovers the bug I don't
think the regression test is strictly speaking necessary (I'm
certainly okay with keeping it without the rwtest dependency).

Martin

> 
> Added:
>     incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp   (with props)
> 
> Added: incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp
> URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp?rev=575614&view=auto
> ==============================================================================
> --- incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp (added)
> +++ incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp Fri Sep 14 03:49:31 2007
> @@ -0,0 +1,92 @@
> +/************************************************************************
> + *
> + * 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 <locale>    // for std::moneypunct, std::messages
> +
> +#include <driver.h>  // for rw_test()
> +
> +template <class charT>
> +void test_moneypunct (charT, const char* name)
> +{
> +    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 ();
> +
> +    rw_assert (fill == buf [sizeof (PunctT)], __FILE__, __LINE__,
> +               "buf [sizeof (std::moneypunct <%s>)] expected %d, got %d\n",
> +               name, int (fill), int (buf [sizeof (PunctT)]));
> +
> +    p->~PunctT ();
> +}
> +
> +template <class charT>
> +void test_messages (charT, const char* name)
> +{
> +    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 ();
> +
> +    rw_assert (fill == buf [sizeof (MessagesT)], __FILE__, __LINE__,
> +               "buf [sizeof (std::messages <%s>)] expected %d, got %d\n",
> +               name, int (fill), int (buf [sizeof (MessagesT)]));
> +
> +    p->~MessagesT ();
> +}
> +
> +static int run_test (int, char**)
> +{
> +    test_moneypunct (char (), "char");
> +    test_messages (char (), "char");
> +
> +#ifndef _RWSTD_NO_WCHAR_T
> +    test_moneypunct (wchar_t (), "wchar_t");
> +    test_messages (wchar_t (), "wchar_t");
> +#endif
> +
> +    return 0;
> +}
> +
> +int main (int argc, char* argv[])
> +{
> +    return rw_test (argc, argv, __FILE__,
> +                    "lib.locale",
> +                    "STDCXX-544",
> +                    run_test,
> +                    "",
> +                    (void*)0);
> +}
> 
> Propchange: incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp
> ------------------------------------------------------------------------------
>     svn:eol-style = native
> 
> Propchange: incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp
> ------------------------------------------------------------------------------
>     svn:keywords = Id
> 
> 
> 


RE: svn commit: r575614 - /incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor
> Sent: Saturday, September 15, 2007 11:34 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r575614 - 
> /incubator/stdcxx/trunk/tests/regress/22.locale.stdcxx-554.cpp
> 
> faridz@apache.org wrote:
> > Author: faridz
> > Date: Fri Sep 14 03:49:31 2007
> > New Revision: 575614
> > 
> > URL: http://svn.apache.org/viewvc?rev=575614&view=rev
> > Log:
> > 2007-09-14 Farid Zaripov <Fa...@epam.com>
> > 
> > 	* 22.locale.stdcxx-554.cpp: Added a regression test for 
> STDCXX-554.
> 
> Good job narrowing it down to a small test case!
> 
> Unless there's no easy way to write the test without 
> involving the driver I think we said regression tests would 
> not depend on it and use the assert macro instead.

  Done: http://svn.apache.org/viewvc?rev=577001&view=rev

> Since the regular unit test exercises the same functionality and 
> uncovers the bug I don't think the regression test is 
> strictly speaking necessary (I'm certainly okay with keeping 
> it without the rwtest dependency).

  The regular test doesn't exercises this bug. The bug was catched
by MSVC runtime checks, but not by the test assertions.

Farid.