Limit line length to 100 chars per line
authorKurt Pattyn <pattyn.kurt@gmail.com>
Sat, 18 Jan 2014 19:50:48 +0000 (20:50 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 20 Jan 2014 12:22:46 +0000 (13:22 +0100)
Change-Id: I2a91033c9882ca54c6fcf26d9eb5a3c91f9e0f7d
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
examples/echoclient/echoclient.cpp
examples/echoserver/echoserver.cpp
examples/simplechat/chatserver.cpp
examples/sslechoclient/sslechoclient.cpp
examples/sslechoserver/sslechoserver.cpp
tests/auto/dataprocessor/tst_dataprocessor.cpp
tests/auto/handshakerequest/tst_handshakerequest.cpp
tests/auto/websocketframe/tst_websocketframe.cpp
tests/auto/websocketprotocol/tst_websocketprotocol.cpp

index 452b20e..f7ffae3 100644 (file)
@@ -59,7 +59,8 @@ EchoClient::EchoClient(const QUrl &url, QObject *parent) :
 void EchoClient::onConnected()
 {
     qDebug() << "Websocket connected";
-    connect(&m_webSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(onTextMessageReceived(QString)));
+    connect(&m_webSocket, SIGNAL(textMessageReceived(QString)), this,
+            SLOT(onTextMessageReceived(QString)));
     m_webSocket.write("Hello, world!");
 }
 //! [onConnected]
index 53abe41..ca0e09f 100644 (file)
@@ -75,7 +75,8 @@ void EchoServer::onNewConnection()
     QWebSocket *pSocket = m_pWebSocketServer->nextPendingConnection();
 
     connect(pSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(processMessage(QString)));
-    connect(pSocket, SIGNAL(binaryMessageReceived(QByteArray)), this, SLOT(processBinaryMessage(QByteArray)));
+    connect(pSocket, SIGNAL(binaryMessageReceived(QByteArray)), this,
+            SLOT(processBinaryMessage(QByteArray)));
     connect(pSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
 
     m_clients << pSocket;
index 5c6116c..44f2748 100644 (file)
@@ -51,7 +51,8 @@ ChatServer::ChatServer(quint16 port, QObject *parent) :
     m_pWebSocketServer(Q_NULLPTR),
     m_clients()
 {
-    m_pWebSocketServer = new QWebSocketServer("Chat Server", QWebSocketServer::SecureModeNonSecure, this);
+    m_pWebSocketServer = new QWebSocketServer("Chat Server", QWebSocketServer::SecureModeNonSecure,
+                                              this);
     if (m_pWebSocketServer->listen(QHostAddress::Any, port))
     {
         qDebug() << "Chat Server listening on port" << port;
index 7160442..8d38b92 100644 (file)
@@ -57,7 +57,8 @@ SslEchoClient::SslEchoClient(const QUrl &url, QObject *parent) :
 void SslEchoClient::onConnected()
 {
     qDebug() << "Websocket connected";
-    connect(&m_webSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(onTextMessageReceived(QString)));
+    connect(&m_webSocket, SIGNAL(textMessageReceived(QString)), this,
+            SLOT(onTextMessageReceived(QString)));
     m_webSocket.write("Hello, world!");
 }
 //! [onConnected]
index e0d638f..f79825d 100644 (file)
@@ -54,7 +54,8 @@ SslEchoServer::SslEchoServer(quint16 port, QObject *parent) :
     m_pWebSocketServer(Q_NULLPTR),
     m_clients()
 {
-    m_pWebSocketServer = new QWebSocketServer("SSL Echo Server", QWebSocketServer::SecureModeSecure, this);
+    m_pWebSocketServer = new QWebSocketServer("SSL Echo Server", QWebSocketServer::SecureModeSecure,
+                                              this);
     QSslConfiguration sslConfiguration;
     QFile certFile(QStringLiteral("./localhost.cert"));
     QFile keyFile(QStringLiteral("./localhost.key"));
index 4fc3a6e..c4a9ed3 100644 (file)
@@ -77,30 +77,30 @@ private Q_SLOTS:
      * Happy Flows
      ***************************************************************************/
     /*!
-      \brief Tests all kinds of valid binary frames, including zero length frames
+      Tests all kinds of valid binary frames, including zero length frames
       */
     void goodBinaryFrame();
     void goodBinaryFrame_data();
 
     /*!
-      \brief Tests all kinds of valid text frames, including zero length frames
+      Tests all kinds of valid text frames, including zero length frames
       */
     void goodTextFrame();
     void goodTextFrame_data();
 
     /*!
-     * \brief Test all kinds of valid control frames.
+     * Test all kinds of valid control frames.
      */
     void goodControlFrame();
 
     /*!
-     * \brief Test all kinds of valid close frames.
+     * Test all kinds of valid close frames.
      */
     void goodCloseFrame();
     void goodCloseFrame_data();
 
     /*!
-     * \brief Test all valid opcodes
+     * Test all valid opcodes
      */
     void goodOpcodes();
     void goodOpcodes_data();
@@ -118,28 +118,30 @@ private Q_SLOTS:
      * Rainy Day Flows
      ***************************************************************************/
     /*!
-        \brief Tests the QWebSocketDataProcessor for correct handling of frames that don't contain the starting 2 bytes.
-        This test is a border case, where not enough bytes are received to even start parsing a frame.
+        Tests the QWebSocketDataProcessor for correct handling of frames that don't
+        contain the starting 2 bytes.
+        This test is a border case, where not enough bytes are received to even start parsing a
+        frame.
         This test does not test sequences of frames, only single frames are tested
      */
     void frameTooSmall();
 
     /*!
-        \brief Tests the QWebSocketDataProcessor for correct handling of frames that are oversized.
+        Tests the QWebSocketDataProcessor for correct handling of frames that are oversized.
         This test does not test sequences of frames, only single frames are tested
      */
     void frameTooBig();
     void frameTooBig_data();
 
     /*!
-        \brief Tests the QWebSocketDataProcessor for the correct handling of malformed frame headers.
+        Tests the QWebSocketDataProcessor for the correct handling of malformed frame headers.
         This test does not test sequences of frames, only single frames are tested
      */
     void invalidHeader();
     void invalidHeader_data();
 
     /*!
-        \brief Tests the QWebSocketDataProcessor for the correct handling of invalid control frames.
+        Tests the QWebSocketDataProcessor for the correct handling of invalid control frames.
         Invalid means: payload bigger than 125, frame is fragmented, ...
         This test does not test sequences of frames, only single frames are tested
      */
@@ -150,13 +152,14 @@ private Q_SLOTS:
     void invalidCloseFrame_data();
 
     /*!
-        \brief Tests the QWebSocketDataProcessor for the correct handling of incomplete size fields for large and big payloads.
+        Tests the QWebSocketDataProcessor for the correct handling of incomplete size fields
+        for large and big payloads.
      */
     void incompleteSizeField();
     void incompleteSizeField_data();
 
     /*!
-        \brief Tests the QWebSocketDataProcessor for the correct handling of incomplete payloads.
+        Tests the QWebSocketDataProcessor for the correct handling of incomplete payloads.
         This includes:
         - incomplete length bytes for large and big payloads (16- and 64-bit values),
         - minimum size representation (see RFC 6455 paragraph 5.2),
@@ -168,7 +171,7 @@ private Q_SLOTS:
     void incompletePayload_data();
 
     /*!
-        \brief Tests the QWebSocketDataProcessor for the correct handling of invalid UTF-8 payloads.
+        Tests the QWebSocketDataProcessor for the correct handling of invalid UTF-8 payloads.
         This test does not test sequences of frames, only single frames are tested
      */
     void invalidPayload();
@@ -178,7 +181,8 @@ private Q_SLOTS:
     void invalidPayloadInCloseFrame_data();
 
     /*!
-      Tests the QWebSocketDataProcessor for the correct handling of the minimum size representation requirement of RFC 6455 (see paragraph 5.2)
+      Tests the QWebSocketDataProcessor for the correct handling of the minimum size representation
+      requirement of RFC 6455 (see paragraph 5.2)
      */
     void minimumSizeRequirement();
     void minimumSizeRequirement_data();
@@ -188,14 +192,17 @@ private:
     void invalidUTF8(const char *dataTag, const char *utf8Sequence, bool isCloseFrame);
     //helper function that constructs a new row of test data for invalid leading field values
     void invalidField(const char *dataTag, quint8 invalidFieldValue);
-    //helper functions that construct a new row of test data for size fields that do not adhere to the minimum size requirement
+    //helper functions that construct a new row of test data for size fields that do not adhere
+    //to the minimum size requirement
     void minimumSize16Bit(quint16 sizeInBytes);
     void minimumSize64Bit(quint64 sizeInBytes);
-    //helper function to construct a new row of test data containing frames with a payload size smaller than indicated in the header
+    //helper function to construct a new row of test data containing frames with a payload size
+    //smaller than indicated in the header
     void incompleteFrame(quint8 controlCode, quint64 indicatedSize, quint64 actualPayloadSize);
     void insertIncompleteSizeFieldTest(quint8 payloadCode, quint8 numBytesFollowing);
 
-    //helper function to construct a new row of test data containing text frames containing  sequences
+    //helper function to construct a new row of test data containing text frames containing
+    //sequences
     void nonCharacterSequence(const char *sequence);
 
     void doTest();
@@ -229,7 +236,8 @@ void tst_DataProcessor::cleanup()
 void tst_DataProcessor::goodBinaryFrame_data()
 {
     QTest::addColumn<QByteArray>("payload");
-    for (int i = 0; i < (65536 + 256); i += 128)    //be sure to get small (< 126 bytes), large (> 125 bytes & < 64K) and big (>64K) frames
+    //be sure to get small (< 126 bytes), large (> 125 bytes & < 64K) and big (>64K) frames
+    for (int i = 0; i < (65536 + 256); i += 128)
     {
         QTest::newRow(QStringLiteral("Binary frame with %1 bytes").arg(i).toLatin1().constData())
                 << QByteArray(i, char(1));
@@ -258,13 +266,15 @@ void tst_DataProcessor::goodBinaryFrame()
     else if (payload.length() < 65536)
     {
         quint16 swapped = qToBigEndian<quint16>(payload.length());
-        const char *wireRepresentation = static_cast<const char *>(static_cast<const void *>(&swapped));
+        const char *wireRepresentation
+                = static_cast<const char *>(static_cast<const void *>(&swapped));
         data.append(char(126)).append(wireRepresentation, 2);
     }
     else
     {
         quint64 swapped = qToBigEndian<quint64>(payload.length());
-        const char *wireRepresentation = static_cast<const char *>(static_cast<const void *>(&swapped));
+        const char *wireRepresentation
+                = static_cast<const char *>(static_cast<const void *>(&swapped));
         data.append(char(127)).append(wireRepresentation, 8);
     }
 
@@ -272,8 +282,10 @@ void tst_DataProcessor::goodBinaryFrame()
     buffer.setData(data);
     buffer.open(QIODevice::ReadOnly);
 
-    QSignalSpy errorReceivedSpy(&dataProcessor, SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
-    QSignalSpy closeReceivedSpy(&dataProcessor, SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy errorReceivedSpy(&dataProcessor,
+                                SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy closeReceivedSpy(&dataProcessor,
+                                SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
     QSignalSpy pingReceivedSpy(&dataProcessor, SIGNAL(pingReceived(QByteArray)));
     QSignalSpy pongReceivedSpy(&dataProcessor, SIGNAL(pongReceived(QByteArray)));
     QSignalSpy binaryFrameReceivedSpy(&dataProcessor, SIGNAL(binaryFrameReceived(QByteArray,bool)));
@@ -304,8 +316,8 @@ void tst_DataProcessor::goodTextFrame_data()
     //test frames with small (< 126), large ( < 65536) and big ( > 65535) payloads
     for (int i = 0; i < (65536 + 256); i += 128)
     {
-        QTest::newRow(QStringLiteral("Text frame with %1 ASCII characters").arg(i).toLatin1().constData())
-                << QByteArray(i, 'a') << i;
+        QTest::newRow(QStringLiteral("Text frame with %1 ASCII characters")
+                      .arg(i).toLatin1().constData()) << QByteArray(i, 'a') << i;
     }
     //test all valid ASCII characters
     for (int i = 0; i < 128; ++i)
@@ -317,8 +329,16 @@ void tst_DataProcessor::goodTextFrame_data()
 
     //the text string reads: Text frame containing Hello-µ@ßöäüàá-UTF-8!!
     //Visual Studio doesn't like UTF-8 in source code, so we use escape codes for the string
-    //The number 22 refers to the length of the string; the length was incorrectly calculated on Visual Studio
-    QTest::newRow(QStringLiteral("Text frame containing Hello-\xC2\xB5\x40\xC3\x9F\xC3\xB6\xC3\xA4\xC3\xBC\xC3\xA0\xC3\xA1-UTF-8!!").toLatin1().constData())
+    //The number 22 refers to the length of the string;
+    //the length was incorrectly calculated on Visual Studio
+
+    //doing extensive QStringLiteral concatenations here, because
+    //MSVC 2010 complains when using concatenation literal strings about
+    //concatenation of wide and narrow strings:
+    //error C2308: concatenating mismatched strings
+    QTest::newRow((QStringLiteral("Text frame containing Hello-") +
+                  QStringLiteral("\xC2\xB5\x40\xC3\x9F\xC3\xB6\xC3\xA4\xC3\xBC\xC3\xA0") +
+                  QStringLiteral("\xC3\xA1-UTF-8!!")).toLatin1().constData())
             << QByteArray::fromHex("48656c6c6f2dc2b540c39fc3b6c3a4c3bcc3a0c3a12d5554462d382121")
             << 22;
 }
@@ -340,13 +360,15 @@ void tst_DataProcessor::goodTextFrame()
     else if (payload.length() < 65536)
     {
         quint16 swapped = qToBigEndian<quint16>(payload.length());
-        const char *wireRepresentation = static_cast<const char *>(static_cast<const void *>(&swapped));
+        const char *wireRepresentation
+                = static_cast<const char *>(static_cast<const void *>(&swapped));
         data.append(char(126)).append(wireRepresentation, 2);
     }
     else
     {
         quint64 swapped = qToBigEndian<quint64>(payload.length());
-        const char *wireRepresentation = static_cast<const char *>(static_cast<const void *>(&swapped));
+        const char *wireRepresentation
+                = static_cast<const char *>(static_cast<const void *>(&swapped));
         data.append(char(127)).append(wireRepresentation, 8);
     }
 
@@ -354,8 +376,10 @@ void tst_DataProcessor::goodTextFrame()
     buffer.setData(data);
     buffer.open(QIODevice::ReadOnly);
 
-    QSignalSpy errorReceivedSpy(&dataProcessor, SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
-    QSignalSpy closeReceivedSpy(&dataProcessor, SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy errorReceivedSpy(&dataProcessor,
+                                SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy closeReceivedSpy(&dataProcessor,
+                                SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
     QSignalSpy pingReceivedSpy(&dataProcessor, SIGNAL(pingReceived(QByteArray)));
     QSignalSpy pongReceivedSpy(&dataProcessor, SIGNAL(pongReceived(QByteArray)));
     QSignalSpy textFrameReceivedSpy(&dataProcessor, SIGNAL(textFrameReceived(QString,bool)));
@@ -386,8 +410,10 @@ void tst_DataProcessor::goodControlFrame()
     QBuffer buffer;
     QWebSocketDataProcessor dataProcessor;
 
-    QSignalSpy closeFrameReceivedSpy(&dataProcessor, SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
-    QSignalSpy errorReceivedSpy(&dataProcessor, SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy closeFrameReceivedSpy(&dataProcessor,
+                                     SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy errorReceivedSpy(&dataProcessor,
+                                SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
     QSignalSpy textFrameReceivedSpy(&dataProcessor, SIGNAL(textFrameReceived(QString,bool)));
     QSignalSpy textMessageReceivedSpy(&dataProcessor, SIGNAL(textMessageReceived(QString)));
     QSignalSpy binaryFrameReceivedSpy(&dataProcessor, SIGNAL(binaryFrameReceived(QByteArray,bool)));
@@ -433,11 +459,14 @@ void tst_DataProcessor::goodCloseFrame_data()
 {
     QTest::addColumn<QString>("payload");
     QTest::addColumn<QWebSocketProtocol::CloseCode>("closeCode");
-    //control frame data cannot exceed 125 bytes; smaller than 124, because we also need a 2 byte close code
+    //control frame data cannot exceed 125 bytes; smaller than 124,
+    //because we also need a 2 byte close code
     for (int i = 0; i < 124; ++i)
     {
-        QTest::newRow(QStringLiteral("Close frame with %1 ASCII characters").arg(i).toLatin1().constData())
-                << QString(i, 'a') << QWebSocketProtocol::CloseCodeNormal;
+        QTest::newRow(QStringLiteral("Close frame with %1 ASCII characters")
+                      .arg(i).toLatin1().constData())
+                << QString(i, 'a')
+                << QWebSocketProtocol::CloseCodeNormal;
     }
     for (int i = 0; i < 126; ++i)
     {
@@ -583,10 +612,12 @@ void tst_DataProcessor::goodCloseFrame()
     buffer.setData(data);
     buffer.open(QIODevice::ReadOnly);
 
-    QSignalSpy errorReceivedSpy(&dataProcessor, SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy errorReceivedSpy(&dataProcessor,
+                                SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
     QSignalSpy pingReceivedSpy(&dataProcessor, SIGNAL(pingReceived(QByteArray)));
     QSignalSpy pongReceivedSpy(&dataProcessor, SIGNAL(pongReceived(QByteArray)));
-    QSignalSpy closeFrameReceivedSpy(&dataProcessor, SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy closeFrameReceivedSpy(&dataProcessor,
+                                     SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
     QSignalSpy textFrameReceivedSpy(&dataProcessor, SIGNAL(textFrameReceived(QString,bool)));
     QSignalSpy textMessageReceivedSpy(&dataProcessor, SIGNAL(textMessageReceived(QString)));
     QSignalSpy binaryFrameReceivedSpy(&dataProcessor, SIGNAL(binaryFrameReceived(QByteArray,bool)));
@@ -663,8 +694,10 @@ void tst_DataProcessor::nonCharacterCodes()
         QByteArray data;
         QBuffer buffer;
         QWebSocketDataProcessor dataProcessor;
-        QSignalSpy errorSpy(&dataProcessor, SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
-        QSignalSpy closeSpy(&dataProcessor, SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
+        QSignalSpy errorSpy(&dataProcessor,
+                            SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
+        QSignalSpy closeSpy(&dataProcessor,
+                            SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
         QSignalSpy pingFrameSpy(&dataProcessor, SIGNAL(pingReceived(QByteArray)));
         QSignalSpy pongFrameSpy(&dataProcessor, SIGNAL(pongReceived(QByteArray)));
         QSignalSpy textFrameSpy(&dataProcessor, SIGNAL(textFrameReceived(QString,bool)));
@@ -706,12 +739,14 @@ void tst_DataProcessor::frameTooSmall()
     firstFrame.append(quint8(QWebSocketProtocol::OpCodeText)).append(char(1))
             .append(QByteArray(1, 'a'));
 
-    //with nothing in the buffer, the dataProcessor should time out and the error should be CloseCodeGoingAway
-    //meaning the socket will be closed
+    //with nothing in the buffer, the dataProcessor should time out
+    //and the error should be CloseCodeGoingAway meaning the socket will be closed
     buffer.setData(data);
     buffer.open(QIODevice::ReadOnly);
-    QSignalSpy errorSpy(&dataProcessor, SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
-    QSignalSpy closeSpy(&dataProcessor, SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy errorSpy(&dataProcessor,
+                        SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy closeSpy(&dataProcessor,
+                        SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
     QSignalSpy pingMessageSpy(&dataProcessor, SIGNAL(pingReceived(QByteArray)));
     QSignalSpy pongMessageSpy(&dataProcessor, SIGNAL(pongReceived(QByteArray)));
     QSignalSpy textMessageSpy(&dataProcessor, SIGNAL(textMessageReceived(QString)));
@@ -881,7 +916,8 @@ void tst_DataProcessor::frameTooBig_data()
     const char *wireRepresentation = 0;
 
     //only data frames are checked for being too big
-    //control frames have explicit checking on a maximum payload size of 125, which is tested elsewhere
+    //control frames have explicit checking on a maximum payload size of 125,
+    //which is tested elsewhere
 
     swapped64 = qToBigEndian<quint64>(QWebSocketDataProcessor::maxFrameSize() + 1);
     wireRepresentation = static_cast<const char *>(static_cast<const void *>(&swapped64));
@@ -922,7 +958,8 @@ void tst_DataProcessor::invalidHeader_data()
     //The second byte contains the MaskFlag and the length of the frame
     QTest::addColumn<quint8>("firstByte");
     QTest::addColumn<quint8>("secondByte");
-    QTest::addColumn<QByteArray>("payload");    //superfluous, but present to be able to call doTest(), which expects a payload field
+    //superfluous, but present to be able to call doTest(), which expects a payload field
+    QTest::addColumn<QByteArray>("payload");
     QTest::addColumn<bool>("isContinuationFrame");
     QTest::addColumn<QWebSocketProtocol::CloseCode>("expectedCloseCode");
 
@@ -1217,11 +1254,18 @@ void tst_DataProcessor::invalidPayload_data(bool isControlFrame)
     invalidUTF8("case 6.12.5",  "80bf80bf", isControlFrame);
     invalidUTF8("case 6.12.6",  "80bf80bf80", isControlFrame);
     invalidUTF8("case 6.12.7",  "80bf80bf80bf", isControlFrame);
-    invalidUTF8("case 6.12.8",  "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbe", isControlFrame);
+    invalidUTF8("case 6.12.8",
+                "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a"
+                "7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbe",
+                isControlFrame);
 
     //6.13: lonely start characters
-    invalidUTF8("case 6.13.1",  "c020c120c220c320c420c520c620c720c820c920ca20cb20cc20cd20ce20cf20d020d120d220d320d420d520d620d720d820d920da20db20dc20dd20de20", isControlFrame);
-    invalidUTF8("case 6.13.2",  "e020e120e220e320e420e520e620e720e820e920ea20eb20ec20ed20ee20", isControlFrame);
+    invalidUTF8("case 6.13.1",
+                "c020c120c220c320c420c520c620c720c820c920ca20cb20cc20cd20ce20cf20d020d120d220"
+                "d320d420d520d620d720d820d920da20db20dc20dd20de20",
+                isControlFrame);
+    invalidUTF8("case 6.13.2",  "e020e120e220e320e420e520e620e720e820e920ea20eb20ec20ed20ee20",
+                isControlFrame);
     invalidUTF8("case 6.13.3",  "f020f120f220f320f420f520f620", isControlFrame);
     invalidUTF8("case 6.13.4",  "f820f920fa20", isControlFrame);
     invalidUTF8("case 6.13.5",  "fc20", isControlFrame);
@@ -1239,7 +1283,8 @@ void tst_DataProcessor::invalidPayload_data(bool isControlFrame)
     invalidUTF8("case 6.14.10", "fdbfbfbfbf", isControlFrame);
 
     //6.15: concatenation of incomplete sequences
-    invalidUTF8("case 6.15.1",  "c0e080f08080f8808080fc80808080dfefbff7bfbffbbfbfbffdbfbfbfbf", isControlFrame);
+    invalidUTF8("case 6.15.1",
+                "c0e080f08080f8808080fc80808080dfefbff7bfbffbbfbfbffdbfbfbfbf", isControlFrame);
 
     //6.16: impossible bytes
     invalidUTF8("case 6.16.1",  "fe", isControlFrame);
@@ -1310,8 +1355,10 @@ void tst_DataProcessor::invalidPayloadInCloseFrame()
     QByteArray data;
     QBuffer buffer;
     QWebSocketDataProcessor dataProcessor;
-    QSignalSpy closeSpy(&dataProcessor, SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
-    QSignalSpy errorSpy(&dataProcessor, SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy closeSpy(&dataProcessor,
+                        SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy errorSpy(&dataProcessor,
+                        SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
     QSignalSpy pingMessageSpy(&dataProcessor, SIGNAL(pingReceived(QByteArray)));
     QSignalSpy pongMessageSpy(&dataProcessor, SIGNAL(pongReceived(QByteArray)));
     QSignalSpy textMessageSpy(&dataProcessor, SIGNAL(textMessageReceived(QString)));
@@ -1376,11 +1423,13 @@ void tst_DataProcessor::incompleteSizeField_data()
     QTest::addColumn<bool>("isContinuationFrame");
     QTest::addColumn<QWebSocketProtocol::CloseCode>("expectedCloseCode");
 
-    //for a frame length value of 126, there should be 2 bytes following to form a 16-bit frame length
+    //for a frame length value of 126
+    //there should be 2 bytes following to form a 16-bit frame length
     insertIncompleteSizeFieldTest(126, 0);
     insertIncompleteSizeFieldTest(126, 1);
 
-    //for a frame length value of 127, there should be 8 bytes following to form a 64-bit frame length
+    //for a frame length value of 127
+    //there should be 8 bytes following to form a 64-bit frame length
     insertIncompleteSizeFieldTest(127, 0);
     insertIncompleteSizeFieldTest(127, 1);
     insertIncompleteSizeFieldTest(127, 2);
@@ -1410,7 +1459,8 @@ void tst_DataProcessor::doTest()
     QByteArray data;
     QBuffer buffer;
     QWebSocketDataProcessor dataProcessor;
-    QSignalSpy errorSpy(&dataProcessor, SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy errorSpy(&dataProcessor,
+                        SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
     QSignalSpy textMessageSpy(&dataProcessor, SIGNAL(textMessageReceived(QString)));
     QSignalSpy binaryMessageSpy(&dataProcessor, SIGNAL(binaryMessageReceived(QByteArray)));
     QSignalSpy textFrameSpy(&dataProcessor, SIGNAL(textFrameReceived(QString, bool)));
@@ -1418,7 +1468,9 @@ void tst_DataProcessor::doTest()
 
     if (isContinuationFrame)
     {
-        data.append(quint8(QWebSocketProtocol::OpCodeText)).append(char(1)).append(QByteArray(1, 'a'));
+        data.append(quint8(QWebSocketProtocol::OpCodeText))
+            .append(char(1))
+            .append(QByteArray(1, 'a'));
     }
     data.append(firstByte).append(secondByte);
     data.append(payload);
@@ -1450,8 +1502,10 @@ void tst_DataProcessor::doCloseFrameTest()
     QByteArray data;
     QBuffer buffer;
     QWebSocketDataProcessor dataProcessor;
-    QSignalSpy closeSpy(&dataProcessor, SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
-    QSignalSpy errorSpy(&dataProcessor, SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy closeSpy(&dataProcessor,
+                        SIGNAL(closeReceived(QWebSocketProtocol::CloseCode,QString)));
+    QSignalSpy errorSpy(&dataProcessor,
+                        SIGNAL(errorEncountered(QWebSocketProtocol::CloseCode,QString)));
     QSignalSpy textMessageSpy(&dataProcessor, SIGNAL(textMessageReceived(QString)));
     QSignalSpy binaryMessageSpy(&dataProcessor, SIGNAL(binaryMessageReceived(QByteArray)));
     QSignalSpy textFrameSpy(&dataProcessor, SIGNAL(textFrameReceived(QString, bool)));
@@ -1570,7 +1624,8 @@ QString tst_DataProcessor::opCodeToString(quint8 opCode)
 void tst_DataProcessor::minimumSize16Bit(quint16 sizeInBytes)
 {
     quint16 swapped16 = qToBigEndian<quint16>(sizeInBytes);
-    const char *wireRepresentation = static_cast<const char *>(static_cast<const void *>(&swapped16));
+    const char *wireRepresentation
+            = static_cast<const char *>(static_cast<const void *>(&swapped16));
     QTest::newRow(QStringLiteral("Text frame with payload size %1, represented in 2 bytes")
                   .arg(sizeInBytes).toLatin1().constData())
             << quint8(FIN | QWebSocketProtocol::OpCodeText)
@@ -1597,7 +1652,8 @@ void tst_DataProcessor::minimumSize16Bit(quint16 sizeInBytes)
 void tst_DataProcessor::minimumSize64Bit(quint64 sizeInBytes)
 {
     quint64 swapped64 = qToBigEndian<quint64>(sizeInBytes);
-    const char *wireRepresentation = static_cast<const char *>(static_cast<const void *>(&swapped64));
+    const char *wireRepresentation
+            = static_cast<const char *>(static_cast<const void *>(&swapped64));
 
     QTest::newRow(QStringLiteral("Text frame with payload size %1, represented in 8 bytes")
                   .arg(sizeInBytes).toLatin1().constData())
@@ -1624,14 +1680,16 @@ void tst_DataProcessor::minimumSize64Bit(quint64 sizeInBytes)
             << QWebSocketProtocol::CloseCodeProtocolError;
 }
 
-void tst_DataProcessor::invalidUTF8(const char *dataTag, const char *utf8Sequence, bool isCloseFrame)
+void tst_DataProcessor::invalidUTF8(const char *dataTag, const char *utf8Sequence,
+                                    bool isCloseFrame)
 {
     QByteArray payload = QByteArray::fromHex(utf8Sequence);
 
     if (isCloseFrame)
     {
         quint16 closeCode = qToBigEndian<quint16>(QWebSocketProtocol::CloseCodeNormal);
-        const char *wireRepresentation = static_cast<const char *>(static_cast<const void *>(&closeCode));
+        const char *wireRepresentation
+                = static_cast<const char *>(static_cast<const void *>(&closeCode));
         QTest::newRow(QStringLiteral("Close frame with invalid UTF8-sequence: %1")
                       .arg(dataTag).toLatin1().constData())
                 << quint8(FIN | QWebSocketProtocol::OpCodeClose)
@@ -1667,7 +1725,8 @@ void tst_DataProcessor::invalidField(const char *dataTag, quint8 invalidFieldVal
                            << QByteArray()
                            << false
                            << QWebSocketProtocol::CloseCodeProtocolError;
-    QTest::newRow(QString::fromLatin1(dataTag).append(" with continuation frame").toLatin1().constData())
+    QTest::newRow(QString::fromLatin1(dataTag).append(" with continuation frame")
+                  .toLatin1().constData())
                             << quint8(FIN | invalidFieldValue)
                             << quint8(0x00)
                             << QByteArray()
@@ -1675,7 +1734,8 @@ void tst_DataProcessor::invalidField(const char *dataTag, quint8 invalidFieldVal
                             << QWebSocketProtocol::CloseCodeProtocolError;
 }
 
-void tst_DataProcessor::incompleteFrame(quint8 controlCode, quint64 indicatedSize, quint64 actualPayloadSize)
+void tst_DataProcessor::incompleteFrame(quint8 controlCode, quint64 indicatedSize,
+                                        quint64 actualPayloadSize)
 {
     QVERIFY(!QWebSocketProtocol::isOpCodeReserved(QWebSocketProtocol::OpCode(controlCode)));
     QVERIFY(indicatedSize > actualPayloadSize);
@@ -1685,8 +1745,13 @@ void tst_DataProcessor::incompleteFrame(quint8 controlCode, quint64 indicatedSiz
 
     if (indicatedSize < 126)
     {
-        QTest::newRow(frameType.append(QStringLiteral(" frame with payload size %1, but only %2 bytes of data")
-                                       .arg(indicatedSize).arg(actualPayloadSize)).toLatin1().constData())
+        //doing extensive QStringLiteral concatenations here, because
+        //MSVC 2010 complains when using concatenation literal strings about
+        //concatenation of wide and narrow strings (error C2308)
+        QTest::newRow(frameType
+                      .append(QStringLiteral(" frame with payload size %1, but only %2 bytes") +
+                              QStringLiteral(" of data")
+                      .arg(indicatedSize).arg(actualPayloadSize)).toLatin1().constData())
                 << quint8(FIN | controlCode)
                 << quint8(indicatedSize)
                 << firstFrame.append(QByteArray(actualPayloadSize, 'a'))
@@ -1696,24 +1761,33 @@ void tst_DataProcessor::incompleteFrame(quint8 controlCode, quint64 indicatedSiz
     else if (indicatedSize <= 0xFFFFu)
     {
         quint16 swapped16 = qToBigEndian<quint16>(static_cast<quint16>(indicatedSize));
-        const char *wireRepresentation = static_cast<const char *>(static_cast<const void *>(&swapped16));
-        QTest::newRow(frameType.append(QStringLiteral(" frame with payload size %1, but only %2 bytes of data")
-                                       .arg(indicatedSize).arg(actualPayloadSize)).toLatin1().constData())
+        const char *wireRepresentation
+                = static_cast<const char *>(static_cast<const void *>(&swapped16));
+        QTest::newRow(
+                    frameType.append(QStringLiteral(" frame with payload size %1, but only ") +
+                                     QStringLiteral("%2 bytes of data")
+                                     .arg(indicatedSize)
+                                     .arg(actualPayloadSize)).toLatin1().constData())
                 << quint8(FIN | controlCode)
                 << quint8(126)
-                << firstFrame.append(QByteArray(wireRepresentation, 2).append(QByteArray(actualPayloadSize, 'a')))
+                << firstFrame.append(QByteArray(wireRepresentation, 2)
+                                     .append(QByteArray(actualPayloadSize, 'a')))
                 << (controlCode == QWebSocketProtocol::OpCodeContinue)
                 << QWebSocketProtocol::CloseCodeGoingAway;
     }
     else
     {
         quint64 swapped64 = qToBigEndian<quint64>(indicatedSize);
-        const char *wireRepresentation = static_cast<const char *>(static_cast<const void *>(&swapped64));
-        QTest::newRow(frameType.append(QStringLiteral(" frame with payload size %1, but only %2 bytes of data")
-                                       .arg(indicatedSize).arg(actualPayloadSize)).toLatin1().constData())
+        const char *wireRepresentation
+                = static_cast<const char *>(static_cast<const void *>(&swapped64));
+        QTest::newRow(frameType
+                      .append(QStringLiteral(" frame with payload size %1, but only %2 bytes ") +
+                              QStringLiteral("of data")
+                                .arg(indicatedSize).arg(actualPayloadSize)).toLatin1().constData())
                 << quint8(FIN | controlCode)
                 << quint8(127)
-                << firstFrame.append(QByteArray(wireRepresentation, 8).append(QByteArray(actualPayloadSize, 'a')))
+                << firstFrame.append(QByteArray(wireRepresentation, 8)
+                                     .append(QByteArray(actualPayloadSize, 'a')))
                 << (controlCode == QWebSocketProtocol::OpCodeContinue)
                 << QWebSocketProtocol::CloseCodeGoingAway;
     }
@@ -1723,14 +1797,19 @@ void tst_DataProcessor::nonCharacterSequence(const char *sequence)
 {
     QByteArray utf8Sequence = QByteArray::fromHex(sequence);
 
-    QTest::newRow(QStringLiteral("Text frame with payload containing the non-control character sequence 0x%1")
+    //doing extensive QStringLiteral concatenations here, because
+    //MSVC 2010 complains when using concatenation literal strings about
+    //concatenation of wide and narrow strings (error C2308)
+    QTest::newRow((QStringLiteral("Text frame with payload containing the non-control character ") +
+                  QStringLiteral("sequence 0x%1"))
                   .arg(QString::fromLocal8Bit(sequence)).toLatin1().constData())
             << quint8(FIN | QWebSocketProtocol::OpCodeText)
             << quint8(utf8Sequence.size())
             << utf8Sequence
             << false;
 
-    QTest::newRow(QStringLiteral("Continuation frame with payload containing the non-control character sequence 0x%1")
+    QTest::newRow((QStringLiteral("Continuation frame with payload containing the non-control ") +
+                  QStringLiteral("character sequence 0x%1"))
                   .arg(QString::fromLocal8Bit(sequence)).toLatin1().constData())
             << quint8(FIN | QWebSocketProtocol::OpCodeContinue)
             << quint8(utf8Sequence.size())
@@ -1740,6 +1819,9 @@ void tst_DataProcessor::nonCharacterSequence(const char *sequence)
 
 void tst_DataProcessor::insertIncompleteSizeFieldTest(quint8 payloadCode, quint8 numBytesFollowing)
 {
+    //doing extensive QStringLiteral concatenations here, because
+    //MSVC 2010 complains when using concatenation literal strings about
+    //concatenation of wide and narrow strings (error C2308)
     QTest::newRow(QStringLiteral("Text frame with payload size %1, with %2 bytes following.")
                   .arg(payloadCode).arg(numBytesFollowing).toLatin1().constData())
             << quint8(FIN | QWebSocketProtocol::OpCodeText)
@@ -1754,7 +1836,8 @@ void tst_DataProcessor::insertIncompleteSizeFieldTest(quint8 payloadCode, quint8
             << QByteArray(numBytesFollowing, quint8(1))
             << false
             << QWebSocketProtocol::CloseCodeGoingAway;
-    QTest::newRow(QStringLiteral("Continuation frame with payload size %1, with %2 bytes following.")
+    QTest::newRow((QStringLiteral("Continuation frame with payload size %1, with %2 bytes ") +
+                  QStringLiteral("following."))
                   .arg(payloadCode).arg(numBytesFollowing).toLatin1().constData())
             << quint8(FIN | QWebSocketProtocol::OpCodeContinue)
             << quint8(payloadCode)
@@ -1766,4 +1849,3 @@ void tst_DataProcessor::insertIncompleteSizeFieldTest(quint8 payloadCode, quint8
 QTEST_MAIN(tst_DataProcessor)
 
 #include "tst_dataprocessor.moc"
-
index a49e5f2..db5ec3c 100644 (file)
@@ -151,9 +151,11 @@ void tst_HandshakeRequest::tst_invalidStream_data()
 
     QTest::newRow("garbage on 2 lines") << QStringLiteral("foofoofoo\r\nfoofoo\r\n\r\n");
     QTest::newRow("garbage on 1 line") << QStringLiteral("foofoofoofoofoo");
-    QTest::newRow("Correctly formatted but invalid fields") << QStringLiteral("VERB RESOURCE PROTOCOL");
+    QTest::newRow("Correctly formatted but invalid fields")
+            << QStringLiteral("VERB RESOURCE PROTOCOL");
 
-    //internally the fields are parsed and indexes are used to convert to a http version for instance
+    //internally the fields are parsed and indexes are used to convert
+    //to a http version for instance
     //this test checks if there doesn't occur an out-of-bounds exception
     QTest::newRow("Correctly formatted but invalid short fields") << QStringLiteral("V R P");
     QTest::newRow("Invalid \\0 character in header") << QStringLiteral("V R\0 P");
@@ -165,7 +167,8 @@ void tst_HandshakeRequest::tst_invalidStream_data()
     //MSVC 2010 complains when using concatenation literal strings about
     //concatenation of wide and narrow strings (error C2308)
     QTest::newRow("Complete header - Invalid websocket version")
-            << QStringLiteral("GET . HTTP/1.1\r\nHost: foo\r\nSec-WebSocket-Version: \xFF\xFF\r\n") +
+            << QStringLiteral("GET . HTTP/1.1\r\nHost: foo\r\nSec-WebSocket-Version: ") +
+               QStringLiteral("\xFF\xFF\r\n") +
                QStringLiteral("Sec-WebSocket-Key: AVDFBDDFF\r\n") +
                QStringLiteral("Upgrade: websocket\r\n") +
                QStringLiteral("Connection: Upgrade\r\n\r\n");
@@ -228,7 +231,11 @@ void tst_HandshakeRequest::tst_invalidStream()
  */
 void tst_HandshakeRequest::tst_multipleValuesInConnectionHeader()
 {
-    QString header = QStringLiteral("GET /test HTTP/1.1\r\nHost: foo.com\r\nSec-WebSocket-Version: 13\r\n") +
+    //doing extensive QStringLiteral concatenations here, because
+    //MSVC 2010 complains when using concatenation literal strings about
+    //concatenation of wide and narrow strings (error C2308)
+    QString header = QStringLiteral("GET /test HTTP/1.1\r\nHost: ") +
+                     QStringLiteral("foo.com\r\nSec-WebSocket-Version: 13\r\n") +
                      QStringLiteral("Sec-WebSocket-Key: AVDFBDDFF\r\n") +
                      QStringLiteral("Upgrade: websocket\r\n") +
                      QStringLiteral("Connection: Upgrade,keepalive\r\n\r\n");
index 36686c5..c818f95 100644 (file)
@@ -98,7 +98,8 @@ QByteArray FrameHelper::wireRepresentation()
     //FIN, opcode
     byte = static_cast<quint8>((m_opCode & 0x0F) | (m_isFinalFrame ? 0x80 : 0x00)); //FIN, opcode
     //RSV1-3
-    byte |= static_cast<quint8>(((m_rsv1 & 0x01) << 6) | ((m_rsv2 & 0x01) << 5) | ((m_rsv3 & 0x01) << 4));
+    byte |= static_cast<quint8>(((m_rsv1 & 0x01) << 6) | ((m_rsv2 & 0x01) << 5) |
+                                ((m_rsv3 & 0x01) << 4));
     wireRep.append(static_cast<char>(byte));
 
     byte = 0x00;
@@ -128,7 +129,8 @@ QByteArray FrameHelper::wireRepresentation()
     //Write mask
     if (m_mask != 0)
     {
-        wireRep.append(static_cast<const char *>(static_cast<const void *>(&m_mask)), sizeof(quint32));
+        wireRep.append(static_cast<const char *>(static_cast<const void *>(&m_mask)),
+                       sizeof(quint32));
     }
     QByteArray tmpData = m_payload;
     if (m_mask)
@@ -557,7 +559,8 @@ void tst_WebSocketFrame::tst_malformedFrames_data()
         uchar swapped[8] = {0};
         qToBigEndian<quint64>(payloadSize, swapped);
         QTest::newRow("Frame too big")
-                << wireRep.left(1).append(bigpayloadIndicator).append(reinterpret_cast<char *>(swapped), 8)
+                << wireRep.left(1).append(bigpayloadIndicator)
+                                  .append(reinterpret_cast<char *>(swapped), 8)
                 << QWebSocketProtocol::CloseCodeTooMuchData;
     }
     //invalid size field
@@ -567,13 +570,15 @@ void tst_WebSocketFrame::tst_malformedFrames_data()
         uchar swapped[8] = {0};
         qToBigEndian<quint64>(payloadSize, swapped);
         QTest::newRow("Highest bit of payload length is set")
-                << wireRep.left(1).append(bigpayloadIndicator).append(reinterpret_cast<char *>(swapped), 8)
+                << wireRep.left(1).append(bigpayloadIndicator)
+                                  .append(reinterpret_cast<char *>(swapped), 8)
                 << QWebSocketProtocol::CloseCodeProtocolError;
 
         payloadSize = 256;
         qToBigEndian<quint64>(payloadSize, swapped);
         QTest::newRow("Overlong 64-bit size field; should be 16-bit")
-                << wireRep.left(1).append(bigpayloadIndicator).append(reinterpret_cast<char *>(swapped), 8)
+                << wireRep.left(1).append(bigpayloadIndicator)
+                                  .append(reinterpret_cast<char *>(swapped), 8)
                 << QWebSocketProtocol::CloseCodeProtocolError;
     }
     //overlong size field
@@ -583,7 +588,8 @@ void tst_WebSocketFrame::tst_malformedFrames_data()
         uchar swapped[2] = {0};
         qToBigEndian<quint16>(payloadSize, swapped);
         QTest::newRow("Overlong 16-bit size field")
-                << wireRep.left(1).append(largepayloadIndicator).append(reinterpret_cast<char *>(swapped), 2)
+                << wireRep.left(1).append(largepayloadIndicator)
+                                  .append(reinterpret_cast<char *>(swapped), 2)
                 << QWebSocketProtocol::CloseCodeProtocolError;
     }
     {
@@ -592,13 +598,15 @@ void tst_WebSocketFrame::tst_malformedFrames_data()
         uchar swapped[8] = {0};
         qToBigEndian<quint64>(payloadSize, swapped);
         QTest::newRow("Overlong 64-bit size field; should be 7-bit")
-                << wireRep.left(1).append(bigpayloadIndicator).append(reinterpret_cast<char *>(swapped), 8)
+                << wireRep.left(1).append(bigpayloadIndicator)
+                                  .append(reinterpret_cast<char *>(swapped), 8)
                 << QWebSocketProtocol::CloseCodeProtocolError;
 
         payloadSize = 256;
         qToBigEndian<quint64>(payloadSize, swapped);
         QTest::newRow("Overlong 64-bit size field; should be 16-bit")
-                << wireRep.left(1).append(bigpayloadIndicator).append(reinterpret_cast<char *>(swapped), 8)
+                << wireRep.left(1).append(bigpayloadIndicator)
+                                  .append(reinterpret_cast<char *>(swapped), 8)
                 << QWebSocketProtocol::CloseCodeProtocolError;
     }
 }
index c092afa..eea434b 100644 (file)
@@ -102,10 +102,20 @@ void tst_WebSocketProtocol::tst_validMasks_data()
     QTest::addColumn<QByteArray>("result");
 
     QTest::newRow("Empty payload") << 0x12345678u << QString() << QByteArray();
-    QTest::newRow("ASCII payload of 8 characters") << 0x12345678u << QStringLiteral("abcdefgh") << QByteArrayLiteral("\x73\x56\x35\x1C\x77\x52\x31\x10");
-    QTest::newRow("ASCII payload of 9 characters") << 0x12345678u << QStringLiteral("abcdefghi") << QByteArrayLiteral("\x73\x56\x35\x1C\x77\x52\x31\x10\x7B");
-    //MSVC doesn't like UTF-8 in source code; the following text is represented in the string below: ∫∂ƒ©øØ
-    QTest::newRow("UTF-8 payload") << 0x12345678u << QString::fromUtf8("\xE2\x88\xAB\xE2\x88\x82\xC6\x92\xC2\xA9\xC3\xB8\xC3\x98") << QByteArrayLiteral("\x2D\x0B\x69\xD1\xEA\xEC");
+    QTest::newRow("ASCII payload of 8 characters")
+            << 0x12345678u
+            << QStringLiteral("abcdefgh")
+            << QByteArrayLiteral("\x73\x56\x35\x1C\x77\x52\x31\x10");
+    QTest::newRow("ASCII payload of 9 characters")
+            << 0x12345678u
+            << QStringLiteral("abcdefghi")
+            << QByteArrayLiteral("\x73\x56\x35\x1C\x77\x52\x31\x10\x7B");
+    //MSVC doesn't like UTF-8 in source code;
+    //the following text is represented in the string below: ∫∂ƒ©øØ
+    QTest::newRow("UTF-8 payload")
+            << 0x12345678u
+            << QString::fromUtf8("\xE2\x88\xAB\xE2\x88\x82\xC6\x92\xC2\xA9\xC3\xB8\xC3\x98")
+            << QByteArrayLiteral("\x2D\x0B\x69\xD1\xEA\xEC");
 }
 
 void tst_WebSocketProtocol::tst_validMasks()