better unittest for IXWebSocketPerMessageDeflateCompressor
This commit is contained in:
parent
e2180a1f31
commit
e9e768a288
6
makefile
6
makefile
@ -104,8 +104,10 @@ test_server:
|
||||
# env TEST=Websocket_server make test
|
||||
# env TEST=Websocket_chat make test
|
||||
# env TEST=heartbeat make test
|
||||
test:
|
||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; ninja install)
|
||||
build_test:
|
||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_TEST=1 .. ; ninja install)
|
||||
|
||||
test: build_test
|
||||
(cd test ; python2.7 run.py -r)
|
||||
|
||||
test_make:
|
||||
|
@ -1,7 +1,9 @@
|
||||
/*
|
||||
* IXSocketTest.cpp
|
||||
* Author: Korchynskyi Dmytro
|
||||
* Copyright (c) 2019 Machine Zone. All rights reserved.
|
||||
* IXWebSocketPerMessageDeflateCodecTest.cpp
|
||||
* Author: Benjamin Sergeant
|
||||
* Copyright (c) 2020 Machine Zone. All rights reserved.
|
||||
*
|
||||
* make build_test && build/test/ixwebsocket_unittest per-message-deflate-codec
|
||||
*/
|
||||
|
||||
#include "IXTest.h"
|
||||
@ -14,22 +16,30 @@ using namespace ix;
|
||||
|
||||
namespace ix
|
||||
{
|
||||
TEST_CASE("per-message-deflate-codec", "[zlib]")
|
||||
std::string compressAndDecompress(const std::string& a)
|
||||
{
|
||||
SECTION("http://google.com")
|
||||
{
|
||||
std::string a = "foobarbaz";
|
||||
std::string b, c;
|
||||
|
||||
WebSocketPerMessageDeflateCompressor compressor;
|
||||
compressor.init(11, true);
|
||||
compressor.compress(a, b);
|
||||
|
||||
WebSocketPerMessageDeflateDecompressor decompressor;
|
||||
decompressor.init(11, true);
|
||||
decompressor.decompress(b, c);
|
||||
|
||||
REQUIRE(a != b);
|
||||
REQUIRE(b != c);
|
||||
REQUIRE(a == c);
|
||||
return c;
|
||||
}
|
||||
|
||||
TEST_CASE("per-message-deflate-codec", "[zlib]")
|
||||
{
|
||||
SECTION("blah")
|
||||
{
|
||||
REQUIRE(compressAndDecompress("") == "");
|
||||
REQUIRE(compressAndDecompress("foo") == "foo");
|
||||
REQUIRE(compressAndDecompress("bar") == "bar");
|
||||
REQUIRE(compressAndDecompress("asdcaseqw`21897dehqwed") == "asdcaseqw`21897dehqwed");
|
||||
REQUIRE(compressAndDecompress("/usr/local/include/ixwebsocket/IXSocketAppleSSL.h") == "/usr/local/include/ixwebsocket/IXSocketAppleSSL.h");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user