I'm writing the unit tests for the major classes of CppUnit.
While writing test for TestResult, I stumbled uppon:
std::vector<TestFailure *>&
TestResult::failures ()
{
ExclusiveZone zone (m_syncObject);
return m_failures;
}
While the method is synchronized, it returns a reference on the vector making the synchronization useless.
Changing this to:
std::vector<TestFailure *> TestResult::failures ()
would solve the problem. Returning by value ensure that the returned vector will stay unmodified.
Anybody see a better solution to this problem ?
Baptiste.
---
Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html
Author of The Text Reformatter, a tool for fanfiction readers and writers.
Language: English, French (Well, I'm French).
|