stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: [PATCH] Update test 22.locale.time.put.mt.cpp to validate results [take 2]
Date Sun, 12 Aug 2007 22:29:01 GMT
Travis Vitek wrote:
> Attached is a patch to enhance the time_put facet mt test. Threads
> verify that the values they put compare equal to those put in the
> primary thread.
> 
> 2007-08-10  Travis Vitek    <vitek@roguewave.com>
> 
>     * 22.locale.time.put.mt.cpp(MyIos, MyStreambuf, MyTimeData)
>     Added structures to simplify testing.
>     (run_test): Build table of in/outputs for verification in test
>     threads.
>     (thread_func): Assert that data written matches expected.
>     (main): Add command line options for specifying number
>     of locales, locale names, and locale usage.

Committed thus: http://svn.apache.org/viewvc?view=rev&rev=565168
I have a couple of minor comments on the patch (see below). I've
also made a few trivial fixups in the next change to the test:
http://svn.apache.org/viewvc?view=rev&rev=565173

> 
> 
> ------------------------------------------------------------------------
> 
> Index: 22.locale.time.put.mt.cpp
> ===================================================================
> --- 22.locale.time.put.mt.cpp	(revision 564268)
> +++ 22.locale.time.put.mt.cpp	(working copy)
> @@ -32,14 +32,14 @@
>  #include <iterator>   // for ostreambuf_iterator
>  #include <locale>     // for locale, time_put
>  
> -#include <cstring>    // for strlen()
> +#include <cstring>    // for strlen ()

As a general rule, please try to avoid unnecessary whitespace
or formatting changes (including code movement). They needlessly
increase the effort required to review patches.

[...]
> @@ -160,19 +214,117 @@
>  static int
>  run_test (int, char**)
>  {
[...]
> +            try {
> +                const std::locale loc (data.locale_name_);
> +
> +                // initialize tm with random but valid values
> +                data.time_.tm_sec  = ++j % 61;
> +                data.time_.tm_min  = ++j % 60;
> +                data.time_.tm_hour = ++j % 12;
> +                data.time_.tm_wday = ++j % 7;
> +                data.time_.tm_mon  = ++j % 12;
> +                data.time_.tm_mday = ++j % 31;
> +                data.time_.tm_yday = ++j % 366;
> +                data.time_.tm_year = ++j;
> +
> +                const char cvtspecs[] = "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%";

These statements can't throw and don't need to be in the try block.
In general, it's best to keep the try block as small as necessary
to guard only the statements that can throw.

This might be a good rule to include in our coding guidelines (when
we finally create the document! :)

Martin

Mime
View raw message