From e2180a1f314dbc89efbdcc97692c202b54f1b87b Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Tue, 7 Jul 2020 20:56:27 -0700 Subject: [PATCH] add unittest for IXWebSocketPerMessageDeflateCompressor --- test/CMakeLists.txt | 1 + ...bSocketPerMessageDeflateCompressorTest.cpp | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/IXWebSocketPerMessageDeflateCompressorTest.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a7081b0c..77facfbe 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -55,6 +55,7 @@ set (SOURCES IXSentryClientTest.cpp IXWebSocketChatTest.cpp IXWebSocketBroadcastTest.cpp + IXWebSocketPerMessageDeflateCompressorTest.cpp ) # Some unittest don't work on windows yet diff --git a/test/IXWebSocketPerMessageDeflateCompressorTest.cpp b/test/IXWebSocketPerMessageDeflateCompressorTest.cpp new file mode 100644 index 00000000..f73ea7cd --- /dev/null +++ b/test/IXWebSocketPerMessageDeflateCompressorTest.cpp @@ -0,0 +1,36 @@ +/* + * IXSocketTest.cpp + * Author: Korchynskyi Dmytro + * Copyright (c) 2019 Machine Zone. All rights reserved. + */ + +#include "IXTest.h" +#include "catch.hpp" +#include +#include +#include + +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