add unittest for IXWebSocketPerMessageDeflateCompressor

This commit is contained in:
Benjamin Sergeant 2020-07-07 20:56:27 -07:00
parent 7c1b57c8cd
commit e2180a1f31
2 changed files with 37 additions and 0 deletions

View File

@ -55,6 +55,7 @@ set (SOURCES
IXSentryClientTest.cpp
IXWebSocketChatTest.cpp
IXWebSocketBroadcastTest.cpp
IXWebSocketPerMessageDeflateCompressorTest.cpp
)
# Some unittest don't work on windows yet

View File

@ -0,0 +1,36 @@
/*
* IXSocketTest.cpp
* Author: Korchynskyi Dmytro
* Copyright (c) 2019 Machine Zone. All rights reserved.
*/
#include "IXTest.h"
#include "catch.hpp"
#include <iostream>
#include <ixwebsocket/IXWebSocketPerMessageDeflateCodec.h>
#include <string.h>
using namespace ix;
namespace ix
{
TEST_CASE("per-message-deflate-codec", "[zlib]")
{
SECTION("http://google.com")
{
std::string a = "foobarbaz";
std::string b, c;
WebSocketPerMessageDeflateCompressor compressor;
compressor.compress(a, b);
WebSocketPerMessageDeflateDecompressor decompressor;
decompressor.decompress(b, c);
REQUIRE(a != b);
REQUIRE(b != c);
REQUIRE(a == c);
}
}
} // namespace ix