Boost logo

Boost Users :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2006-07-30 05:11:08


"Tan Zhi" <rockonedge_at_[hidden]> wrote in message
news:44CC220C.8080405_at_gmail.com...
> According to the document, BOOST_CHECK is the same as BOST_CHECK_EQUAL.
> However,I found an exception. Which is listed below,
> where m_mmf.SetLngGetString(1033, 1) returns a const wchar_t* type.
>
> Interestingly, the first two tests fail, while the last two pass.
>
> BOOST_CHECK(L"A" == m_mmf.SetLngGetString(1033, 1));
>
> BOOST_CHECK(m_mmf.SetLngGetString(1033, 1) == L"A" );

This actually perform pointers comparizons and almost never produce true.

>
>
> BOOST_CHECK_EQUAL(L"A", m_mmf.SetLngGetString(1033, 1));
>
> BOOST_CHECK_EQUAL(m_mmf.SetLngGetString(1033, 1), L"A");

Boost.Test includes special treatement to C strings comparisons. As a result
actual value are compared not the pointers. That's another reason to prefer
BOOST_CHECK_EQUAL to BOOST_CHECK.

Gennadiy

>
> Can any one please help to explain it? Thanks


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