Boost logo

Boost Users :

Subject: [Boost-users] Change format output for strings
From: Mads Bondo Dydensborg (mbd_at_[hidden])
Date: 2008-10-01 07:34:24


Hi there.

I have some unittests that compare strings, that look something like this,
when they are run, and fails:

boost_extract_xml_from_es_task_package.cc(106): error in "itemorder":
check "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>todo" ==
output_24575997 failed [<?xml version="1.0" encoding="ISO-8859-1"?>todo !=
<?xml version="1.0" encoding="ISO-8859-1"?><!-- Alle
niveauer --><ill5:ILL-APDU
xmlns:ill5="http://www.loc.gov/z3950/agency/defns/ill5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loc.gov/z3950/agency/defns/ill5
http://www.bs.dk/standards/illv5.xsd"><ill5:ILL-Request-1
protocol-version-num="2" place-on-hold="1" ><transaction-id
transaction-qualifier="87792"
transaction-group-qualifier="87792"><initial-requester-id><person-or-institution-symbol><institution-symbol>DK-726000</institution-symbol></person-or-institution-symbol></initial-requester-id></transaction-id><service-date-time><date-time-of-this-service
date="2008-09-27"></date-time-of-this-service></service-date-time><requester-id><person-or-institution-symbol><institution-symbol>DK-726000</institution-symbol></person-or-institution-symbol></requester-id><responder-id><person-or-institution-symbol><institution-symbol>720100</institution-symbol></person-or-institution-symbol></responder-id><iLL-service-type>1</iLL-service-type><item-id><held-medium-type></held-medium-type><system-no>id=42780960
og lok=870970</system-no></item-id></ill5:ILL-Request-1></ill5:ILL-APDU>]

Now, this is almost impossible to read.

Is there a way to massage the framework into giving output similar to how
nunit does it, something like:

boost_extract_xml_from_es_task_package.cc(106): error in "itemorder":
check "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>todo" ==
output_24575997 failed
output differs at position 42
expected ...ISO-8859-1"?><!-- Alle niveauer ...
got ...ISO-8859-1"?>todo<eof>
                         ^

(You need a fixed font, I reckon).

In the example I know it is quite simple, but I wanted to spare you for some
functions we have, where we have to run wdiff on them to see the difference.
(And, not to worry, we are not generating XML by hand, but this was the
example I had ready). It would be cool to have this in the testing
framework - writing code to do this on two different strings are no problem,
but I have absolutely no clue on how to the test framework to do it. I got as
long as

BOOST_TEST_DECL
void check_impl( predicate_result const& pr, wrap_stringstream& check_descr,
                 const_string file_name, std::size_t line_num,
                 tool_level tl, check_type ct,
                 std::size_t num_args, ... );

before I gave up - perhaps someone else knows how to get further?

Thanks in advance

Mads

-- 
Med venlig hilsen/Regards
Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77 34

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net