From cadc4b42bacf959258f7d4b19e93d02c02b63449 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Thu, 8 May 2014 13:21:42 -0400 Subject: Cpp{Tools,Editor}: Tests: Use QString instead of QByteArray This is necessary in order to add tests with multi-byte UTF-8 code points. Otherwise the initial and target source code marker positions will be calculated on the QByteArray (test code) but used with a QString (editor document). Change-Id: I108961b13d32912a4d3193cf26eb59f65d296f57 Reviewed-by: Erik Verbruggen --- src/plugins/cpptools/cpptoolstestcase.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/plugins/cpptools/cpptoolstestcase.cpp') diff --git a/src/plugins/cpptools/cpptoolstestcase.cpp b/src/plugins/cpptools/cpptoolstestcase.cpp index 12c0218270..05eb856821 100644 --- a/src/plugins/cpptools/cpptoolstestcase.cpp +++ b/src/plugins/cpptools/cpptoolstestcase.cpp @@ -61,20 +61,21 @@ namespace CppTools { namespace Tests { TestDocument::TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker) - : m_fileName(fileName), m_source(source), m_cursorMarker(cursorMarker) + : m_fileName(QString::fromUtf8(fileName)) + , m_source(QString::fromUtf8(source)) + , m_cursorMarker(cursorMarker) {} QString TestDocument::filePath() const { - const QString fileNameAsString = QString::fromUtf8(m_fileName); - if (!QFileInfo(fileNameAsString).isAbsolute()) - return QDir::tempPath() + QLatin1Char('/') + fileNameAsString; - return fileNameAsString; + if (!QFileInfo(m_fileName).isAbsolute()) + return QDir::tempPath() + QLatin1Char('/') + m_fileName; + return m_fileName; } bool TestDocument::writeToDisk() const { - return TestCase::writeFile(filePath(), m_source); + return TestCase::writeFile(filePath(), m_source.toUtf8()); } TestCase::TestCase(bool runGarbageCollector) -- cgit v1.2.1