incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: svn commit: r675044 - in /stdcxx/branches/4.3.x: include/rw/_tuple.h include/tuple tests/utilities/20.tuple.cnstr.cpp tests/utilities/20.tuple.creation.cpp tests/utilities/20.tuple.h tests/utilities/20.tuple.helpers.cpp
Date Wed, 09 Jul 2008 23:12:02 GMT
Eric Lemings wrote:
>  
[...]
> With the following change:
> 
> 	Index:
> /work/stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp
> 	
> ===================================================================
> 	---
> /work/stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp
> (revision 675050)
> 	+++
> /work/stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp
> (working copy)
> 	@@ -74,18 +73,20 @@
[...]
> It appears that pointer values are not guaranteed to be equal when
> converting between pointer types.

They must be. I see the assertions in the test but the small
program below works fine.

On an unrelated note, though: While working with the test
I found the heavy use of macros and globals quite confusing.
It makes it very difficult to find and track the tested
values, and virtually impossible to extend with new test
cases.

The approach I've found to work better is splitting up the
test into one or some other small number of worker functions
parametrized on all the arguments and expected values and
their types (if necessary) and other higher level functions,
for example one for each overload of the tested function,
with individual test cases and literal values of arguments
and expected results. You can find examples of such tests
in the tests/localization directory, such as all the
22.locale.{money,num,time}.{get,put}.cpp tests. I suggest
you follow this example in the tuple tests as well.

Martin

#include <cassert>
#include <tuple>

int main ()
{
     const char* s = "string";

     {
         std::tuple<const char*> x (s);
         const char* const y = std::get<0>(x);

         assert (y == s);
     }
     {
         std::tuple<long, const char*> x (0, s);
         const char* const y = std::get<1>(x);

         assert (y == s);
     }
}


Mime
View raw message