From 7edd623957b958d7d3db20772571810d7be9da85 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 1 Feb 2012 20:47:26 +0100 Subject: Fix QTextStream and QDebug operator<< for QLatin1String QLatin1String now has a constructor that takes explicit length, which makes it possible to create a QLatin1String that isn't null-terminated. Made the QTextStream and QDebug << operators work in that case. Change-Id: I94d051ce2ebfb2d2a403b96d25e040c80a54bf7c Reviewed-by: Lars Knoll --- tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp') diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 7d5db69ffd..01aecc2a21 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -170,6 +170,7 @@ private slots: // text write operators void string_write_operator_ToDevice_data(); void string_write_operator_ToDevice(); + void latin1String_write_operator_ToDevice(); // other void skipWhiteSpace_data(); @@ -2384,6 +2385,20 @@ void tst_QTextStream::string_write_operator_ToDevice() } } +void tst_QTextStream::latin1String_write_operator_ToDevice() +{ + QBuffer buf; + buf.open(QBuffer::WriteOnly); + QTextStream stream(&buf); + stream.setCodec(QTextCodec::codecForName("ISO-8859-1")); + stream.setAutoDetectUnicode(true); + + stream << QLatin1String("No explicit length"); + stream << QLatin1String("Explicit length - ignore this part", 15); + stream.flush(); + QCOMPARE(buf.buffer().constData(), "No explicit lengthExplicit length"); +} + // ------------------------------------------------------------------------------ void tst_QTextStream::useCase1() { -- cgit v1.2.3