On 02/26/10 14:32, Terrence Enger wrote:
I am looking at issue 109146 "Assertion: Error: seekEntry() Bad map ..."
<http://www.openoffice.org/issues/show_bug.cgi?id=109146>. It just
happens to be the first assertion that I saw triggered in my first
non-product build.
The failing assertion is in a function defined outside of any class, but
the cppunit tutorials I have found all have object-oriented examples.
I'll see how I get along.
One good test is to make the unchanged assertion fire, right? To
accomplish this under different compilers, I think the test program is
going to compare the addresses of independent variables, and that gives
results which are not defined by the C++ standard. (Well, that's if my
very old memory is correct.) Anyway, before this is done, I shall need
help to find a compiler which sends the test program down the "other"
path by allocating stack variables in the other order.
This issue is probably a bad choice to write a test for (at least a bad
choice for starters), for at least two reasons:
- Checking that an assertion fires is not easy. (It will become easier
when <http://qa.openoffice.org/issues/show_bug.cgi?id=109142> "Let
assertions abort" is fixed, if you assume that observing an abort
implies a fired assertion.)
- The DBG_ASSERT expression in the issue is wrong, whether or not it
fires depends on factors outside the C++ standard. It is generally not
possible to write standard C++ code that reliably causes the assertion
to fire or not to fire. (As you noted already. However, note that this
is not about stack variables, but about string literals in a library's
(read-only) data segment.)
That same test will have to cast away constness of
MediaTypeEntry::m_pTypeName, and that is a bad thing to do. But I am
*trying* to screw things up. Does that give me a pass?
Why would you need to cast away constness?
-Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org