[Interest] Using QT and boost unit test: problem with QString

Heidler, Kirstin (GE Oil & Gas) Kirstin.Heidler at ge.com
Fri Sep 21 12:01:53 CEST 2012


I have to use boost unit test (not my choice). QT unit tests were
working fine.

 

I have the problem, that somewhere boost wants to append a const QString
to an ostream.(I do not exactly know where this call occurs, since it is
hidden in macros, but I know it is for writing a log file)

So I get the compile error C2697:  binary operator '<<': no operator
found which takes a right-hand operand of type 'const QString' (or there
is no acceptable conversion).

 

I don't want to change boost source files. Is there another way to
resolve this error?

Can I define this operator somewhere so boost will find it when trying
to write it's log?

Or maybe you know how to prevent it in the first place?

 

This should be the testcase, that causes the error:

 

BOOST_AUTO_TEST_CASE(testNameReadCorrectly){

    FileParser parser = FileParser::FileParser(

                "---FilePath---");

    parser.readName();

    QString name = "---FileName---";

    BOOST_CHECK_EQUAL(parser.getFileData().getName(), name);

}

 

(Notice that in the qoriginal the path and name look different. ;))

 

The error then occurs here:

 

   struct print_log_value {

       void    operator()( std::ostream& ostr, T const& t )

       {

           // avoid warning: 'boost::test_tools::<unnamed>::dummy_cond'
defined but not used 

           if (::boost::test_tools::dummy_cond) {}

 

           typedef typename
mpl::or_<is_array<T>,is_function<T>,is_abstract<T> >::type cant_use_nl;

 

           set_precision( ostr, cant_use_nl() );

 

/* error*/ ostr << t; // by default print the value

    }

 

Thank you for your help,

Kirstin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120921/e082afee/attachment.html>


More information about the Interest mailing list