summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKurt Pattyn <pattyn.kurt@gmail.com>2013-10-19 13:19:04 +0200
committerKurt Pattyn <pattyn.kurt@gmail.com>2013-10-19 14:26:44 +0200
commit4258cb14c521ab6ba14e5aad953f41f3c9e8e471 (patch)
tree713a823a6962b89f606f3100e7e2b54ffd012139 /tests
parenteb6246203f58dff9057ef6c70a22487104afeb45 (diff)
downloadqtwebsockets-4258cb14c521ab6ba14e5aad953f41f3c9e8e471.tar.gz
Add test for constructor and assignment operator
Change-Id: I4a475ca6e173a7102d465d821f1427d0b6d206d0 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/websocketframe/tst_websocketframe.cpp57
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/auto/websocketframe/tst_websocketframe.cpp b/tests/auto/websocketframe/tst_websocketframe.cpp
index c53d02c..ccce12c 100644
--- a/tests/auto/websocketframe/tst_websocketframe.cpp
+++ b/tests/auto/websocketframe/tst_websocketframe.cpp
@@ -153,6 +153,7 @@ private Q_SLOTS:
void cleanup();
void tst_initialization();
+ void tst_copyConstructorAndAssignment();
void tst_goodFrames_data();
void tst_goodFrames();
@@ -191,6 +192,60 @@ void tst_WebSocketFrame::tst_initialization()
QCOMPARE(frame.payload().length(), 0);
}
+void tst_WebSocketFrame::tst_copyConstructorAndAssignment()
+{
+ FrameHelper frameHelper;
+ frameHelper.setRsv1(0);
+ frameHelper.setRsv2(0);
+ frameHelper.setRsv3(0);
+ frameHelper.setFinalFrame(true);
+ frameHelper.setMask(1234u);
+ frameHelper.setOpCode(QWebSocketProtocol::OC_BINARY);
+ frameHelper.setPayload(QByteArray("12345"));
+
+ QByteArray payload = frameHelper.wireRepresentation();
+ QBuffer buffer(&payload);
+ buffer.open(QIODevice::ReadOnly);
+
+ QWebSocketFrame frame = QWebSocketFrame::readFrame(&buffer);
+ buffer.close();
+
+ {
+ QWebSocketFrame other(frame);
+ QCOMPARE(other.closeCode(), frame.closeCode());
+ QCOMPARE(other.closeReason(), frame.closeReason());
+ QCOMPARE(other.hasMask(), frame.hasMask());
+ QCOMPARE(other.isContinuationFrame(), frame.isContinuationFrame());
+ QCOMPARE(other.isControlFrame(), frame.isControlFrame());
+ QCOMPARE(other.isDataFrame(), frame.isDataFrame());
+ QCOMPARE(other.isFinalFrame(), frame.isFinalFrame());
+ QCOMPARE(other.isValid(), frame.isValid());
+ QCOMPARE(other.mask(), frame.mask());
+ QCOMPARE(other.opCode(), frame.opCode());
+ QCOMPARE(other.payload(), frame.payload());
+ QCOMPARE(other.rsv1(), frame.rsv1());
+ QCOMPARE(other.rsv2(), frame.rsv2());
+ QCOMPARE(other.rsv3(), frame.rsv3());
+ }
+ {
+ QWebSocketFrame other = frame;
+ QCOMPARE(other.closeCode(), frame.closeCode());
+ QCOMPARE(other.closeReason(), frame.closeReason());
+ QCOMPARE(other.hasMask(), frame.hasMask());
+ QCOMPARE(other.isContinuationFrame(), frame.isContinuationFrame());
+ QCOMPARE(other.isControlFrame(), frame.isControlFrame());
+ QCOMPARE(other.isDataFrame(), frame.isDataFrame());
+ QCOMPARE(other.isFinalFrame(), frame.isFinalFrame());
+ QCOMPARE(other.isValid(), frame.isValid());
+ QCOMPARE(other.mask(), frame.mask());
+ QCOMPARE(other.opCode(), frame.opCode());
+ QCOMPARE(other.payload(), frame.payload());
+ QCOMPARE(other.rsv1(), frame.rsv1());
+ QCOMPARE(other.rsv2(), frame.rsv2());
+ QCOMPARE(other.rsv3(), frame.rsv3());
+ }
+}
+
void tst_WebSocketFrame::tst_goodFrames_data()
{
QTest::addColumn<int>("rsv1");
@@ -286,7 +341,7 @@ void tst_WebSocketFrame::tst_goodFrames()
buffer.open(QIODevice::ReadOnly);
QWebSocketFrame frame = QWebSocketFrame::readFrame(&buffer);
buffer.close();
- QCOMPARE(frame.isValid(), true);
+ QVERIFY(frame.isValid());
QCOMPARE(frame.rsv1(), rsv1);
QCOMPARE(frame.rsv2(), rsv2);
QCOMPARE(frame.rsv3(), rsv3);