unit testing - googletest printing COleDateTime values -



unit testing - googletest printing COleDateTime values -

i have integrated googletest our mfc application. while writing tests involving coledatetime objects came across next warning:

1>gtest/gtest-printers.h(169) : warning c4244: 'initializing' : conversion 'date' 'const testing::internal::biggestint', possible loss of info 1>gtest/gtest-printers.h(168) : while compiling class template fellow member function 'void testing::internal2::typewithoutformatter<t,ktypekind>::printvalue(const t &,std::ostream *)'

the test following:

test(functiontest, sumdays) { coledatetime res = sumdays(coledatetime(2010,10,31,0,0,0), 1); expect_eq(coledatetime(2010,11,01,0,0,0), res); }

the problem cannot add together << operator or printto method documentation announces. allot more tests going involve date values want avoid inline solution documentation refers to.

is there solution command print string coledatetime values?

the current output comes out like:

<failure message="value of: res&#x0a; actual: 40512&#x0a;expected: coledatetime(2010,10,30,0,0,0)&#x0a;which is: 40481" type=""><![cdata[.\code.cpp:6837 value of: res actual: 40512 expected: coledatetime(2010,10,30,0,0,0) is: 40481]]></failure>

notice actual value!

i had same porblem , figured out, - in contrast caerbanogs statement - implementing printto-function(s) helps indeed. 1 of import thing create sure class 1 "extends" behaviour googletest has exactly same namespace printto-function.

in case namespace atl!

this leads next solution coledatetime , coledatetimespan:

namespace atl { void printto(const coledatetime& dtdatum, ::std::ostream* os) { // want additional format, append human readable notion *os << dtdatum.m_dt << " (" << (lpcstr)dtdatum.format(_t("%d.%m.%y %h:%m:%s")) << ")"; } void printto(const coledatetimespan& dsspanne, ::std::ostream* os) { *os << dsspanne.m_span; } }

just set place, can include googletest-projects (if have more one).

at lastly works me :-)

unit-testing googletest

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -