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