diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-12-22 00:56:20 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-12-22 00:56:20 (GMT) |
commit | 6db81533a21b08e9dffd7ef4431443732bda2f28 (patch) | |
tree | aaec35a072f3062c8e2335a006ac6a251196f67a /tests/auto/qtextstream/tst_qtextstream.cpp | |
parent | d37a3529ec883985b2967265f0797d749db74308 (diff) | |
parent | 435eeaac07e50db4938066e36cd1a778c4523493 (diff) | |
download | Qt-6db81533a21b08e9dffd7ef4431443732bda2f28.zip Qt-6db81533a21b08e9dffd7ef4431443732bda2f28.tar.gz Qt-6db81533a21b08e9dffd7ef4431443732bda2f28.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (33 commits)
Add inter-process binary shader cache for MeeGo
Track average wait times under our maximum spin time threshold
Store and track spin times in nanosecond resolution
Optimize adaptive spinning mutex code
Improve QMutex contention performance on Linux
Improve QMutex contention performance on Mac OS X
Disable spinning under lock contention on single CPU machines
Remove unnecessary testAndSetAcquire from QMutex::lockInternal()
Move contender count maintenance to QMutexPrivate
test contention when using 2 mutexes
Ensure that every thread does contend in the contention tests
Add baseline test data to measure test overhead
Test contention performance for long (10ms) critical sections
Add a benchmark for contended and uncontended QMutex performance
Removed QMutexPrivate::self() declaration
Add QElapsedTimer::nsecsElapsed() const
Delay creation of the process manager
Make the QRasterPaintEngineState copy constructor cheaper.
Micro-optimization for QSpanData::setup()
define FSCTL_SET_REPARSE_POINT in test header
...
Diffstat (limited to 'tests/auto/qtextstream/tst_qtextstream.cpp')
-rw-r--r-- | tests/auto/qtextstream/tst_qtextstream.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index 4c78ef0..005f686 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -228,6 +228,7 @@ private slots: void status_real_read(); void status_integer_read(); void status_word_read(); + void status_write_error(); // use case tests void useCase1(); @@ -4176,6 +4177,42 @@ void tst_QTextStream::status_word_read() QCOMPARE(s.status(), QTextStream::ReadPastEnd); } +class FakeBuffer : public QBuffer +{ +protected: + qint64 writeData(const char *c, qint64 i) { return m_lock ? 0 : QBuffer::writeData(c, i); } +public: + FakeBuffer(bool locked = false) : m_lock(locked) {} + void setLocked(bool locked) { m_lock = locked; } +private: + bool m_lock; +}; + +void tst_QTextStream::status_write_error() +{ + FakeBuffer fb(false); + QVERIFY(fb.open(QBuffer::ReadWrite)); + QTextStream fs(&fb); + fs.setCodec(QTextCodec::codecForName("latin1")); + /* first write some initial content */ + fs << "hello"; + fs.flush(); + QCOMPARE(fs.status(), QTextStream::Ok); + QCOMPARE(fb.data(), QByteArray("hello")); + /* then test that writing can cause an error */ + fb.setLocked(true); + fs << "error"; + fs.flush(); + QCOMPARE(fs.status(), QTextStream::WriteFailed); + QCOMPARE(fb.data(), QByteArray("hello")); + /* finally test that writing after an error doesn't change the stream any more */ + fb.setLocked(false); + fs << "can't do that"; + fs.flush(); + QCOMPARE(fs.status(), QTextStream::WriteFailed); + QCOMPARE(fb.data(), QByteArray("hello")); +} + void tst_QTextStream::task180679_alignAccountingStyle() { { |