Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2003-10-14 04:21:05


I might have understood this all wrong, but maybe this will help you:

http://builder.com.com/5100-6370-5079969.html?tag=crm

You can write what you wish, and as many manipulators as you wish.
And at the end, it's automatically converted to string.

Please email me if you want the source code.

Best,
John

----- Original Message -----
From: "Paul A. Bristow" <boost_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Friday, October 10, 2003 9:37 PM
Subject: RE: [boost] Boost Test tools to test manipulators
likehex,setw(15)...

> | -----Original Message-----
> | From: boost-bounces_at_[hidden]
> | [mailto:boost-bounces_at_[hidden]]On Behalf Of Scott Woods
> | Sent: Thursday, October 02, 2003 10:49 PM
> | To: Boost mailing list
> | Subject: Re: [boost] Boost Test tools to test manipulators
>
> | like hex,setw(15)...
> |
> | i'm guessing that you want to add a function
> | something like;
> |
> | template <typename T>
> | string toString( T value, SMANIP(int) m )
>
> template <typename T>
> string toString(T value, std::_Smanip<std::streamsize> m)
> { // Convert T to string, using manipulator with one int parameter like
setw,
> setprecision
> // Note uses default stream values, unless overwritten by manipulator.
> ostringstream oss;
> oss << m << value;
> cout << "value|" << value << "|" << ", toString |" << oss.str() << "|" <<
> endl; // for test only.
> // Example: toString(99, setw(15))
> return oss.str();
> }
>
> works as you suggest, but after all the help from you I have regretfully
> concluded that because the most important part is to test COMBINATIONS of
> SEVERAL manipulators both std:: AND my own fancy ones, this approach of
passing
> manipulators is flawed.
>
> So I have resorted to the uglier:
> {
> int value = 15;
> ostringstream oss;
> setMyStreamDefaults; // xalloc ...
> oss << "" << hex << showbase << setw(10) << setprecision(4) //
> std::manipulators
> << myManipulator1 << myManipulator2 // My own parameterless
> << myIntManipulator1(5) << myIntManipulator2(42)// some int parameter
ones
> << value;
> BOOST_CHECK_EQUAL(oss.str(), " 0xf");
> }
>
> And fear a nasty macro coming on ...
>
> But many thanks to you, and Brian McNamara.
>
> However Gennadiy might like to add Brian's makeManip stuff to allow
>
> BOOST_MESSAGE("i = " << makeManip(cerr)(hex) << i );
>
> in case anyone wants to do this.
>
> It might also be nice to be able to write
> BOOST_CHECK_EQUAL("i = " << makeManip(cerr)(hex) << i, " 0xf");
> or
> BOOST_CHECK_EQUAL_STRING("i = " << makeManip(cerr)(hex) << i, "
0xf");
>
> (Although it wouldn't solve my particular problem).
>
> Paul
>
> Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
> +44 1539 561830 Mobile +44 7714 33 02 04
> mailto:pbristow_at_[hidden]
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk