diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-07-29 00:02:42 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-07-29 10:56:42 +0100 |
commit | 8291b5884c1c4c5278473886cdf1bb0f022aac99 (patch) | |
tree | fabf4cca874951f459e63145f1a94aff1be540d4 /tools/qa/cppunit | |
parent | 990083e87531999f7c3d2c34c8205ce63bf294aa (diff) |
make stream operators leave variables in original state on failure
this aligns them with the behaviour of std::stream, and makes things
like
sal_uInt32 n(0);
rSt >> n;
if (n)
{
...
}
safe if there was a short read of e.g. 3 bytes instead of the required 4
Diffstat (limited to 'tools/qa/cppunit')
-rw-r--r-- | tools/qa/cppunit/test_streamstate.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/qa/cppunit/test_streamstate.cxx b/tools/qa/cppunit/test_streamstate.cxx index c2a4be0c5e00..182ad6c45561 100644 --- a/tools/qa/cppunit/test_streamstate.cxx +++ b/tools/qa/cppunit/test_streamstate.cxx @@ -94,6 +94,9 @@ namespace //yet, the read didn't succeed CPPUNIT_ASSERT(!aMemStream.good()); + //set things up so that there is only one byte available on an attempt + //to read a two-byte sal_uInt16. The byte should be consumed, but the + //operation should fail, and tools_b should remain unchanged, sal_uInt16 tools_b = 0x1122; aMemStream.SeekRel(-1); CPPUNIT_ASSERT(!aMemStream.eof()); @@ -101,7 +104,7 @@ namespace aMemStream >> tools_b; CPPUNIT_ASSERT(!aMemStream.good()); CPPUNIT_ASSERT(aMemStream.eof()); -// CPPUNIT_ASSERT(tools_b == 0x1122); //nasty, real nasty + CPPUNIT_ASSERT(tools_b == 0x1122); iss.clear(); iss.seekg(0); |