This repository has been archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solved bug on put command and added tests to cover the case
- Loading branch information
kanekotic
committed
Aug 22, 2016
1 parent
5d3e444
commit 20d093d
Showing
4 changed files
with
80 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#include <gtest/gtest.h> | ||
#include <jsonrpcresponse.h> | ||
#include <jsonrpcrequest.h> | ||
|
||
using namespace P2S::Lib; | ||
|
||
TEST(RPCResponseTest, ValidJsonRpcResponseTest) { | ||
ValidJsonRpcResponse response("it works", "10"); | ||
EXPECT_EQ("{\"id\":\"10\",\"jsonrpc\":\"2.0\",\"result\":\"it works\"}", response.Serialize()); | ||
TEST(RPCRequestTest, ParseCorrectJsonRPC) { | ||
JsonRpcRequest request; | ||
ASSERT_NO_THROW(request.Deserialize("{\"jsonrpc\": \"2.0\", \"method\":\"example\", \"params\": [42], \"id\": 2}")); | ||
} | ||
|
||
TEST(RPCResponseTest, ErrorJsonRpcResponseTest) { | ||
ErrorJsonRpcResponse response(-32700,"Parse Error", "10"); | ||
EXPECT_EQ("{\"error\":{\"code\":-32700,\"data\":\"\",\"message\":\"Parse Error\"},\"id\":\"10\",\"jsonrpc\":\"2.0\"}", response.Serialize()); | ||
TEST(RPCRequestTest, ParseIncorrectJsonRPC) { | ||
JsonRpcRequest request; | ||
ASSERT_ANY_THROW(request.Deserialize("{\"jsonrpc\": \"2.0\".... \"method\":\"example\", \"id\": 2}")); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
#include <gtest/gtest.h> | ||
#include <jsonrpcrequest.h> | ||
#include <jsonrpcresponse.h> | ||
|
||
using namespace P2S::Lib; | ||
|
||
TEST(RPCRequestTest, ParseCorrectJsonRPC) { | ||
JsonRpcRequest request; | ||
ASSERT_NO_THROW(request.Deserialize("{\"jsonrpc\": \"2.0\", \"method\":\"example\", \"params\": [42], \"id\": 2}")); | ||
TEST(RPCResponseTest, ValidJsonRpcResponseTest) { | ||
ValidJsonRpcResponse response("it works", "10"); | ||
EXPECT_EQ("{\"id\":\"10\",\"jsonrpc\":\"2.0\",\"result\":\"it works\"}", response.Serialize()); | ||
} | ||
|
||
TEST(RPCRequestTest, ParseIncorrectJsonRPC) { | ||
JsonRpcRequest request; | ||
ASSERT_ANY_THROW(request.Deserialize("{\"jsonrpc\": \"2.0\".... \"method\":\"example\", \"id\": 2}")); | ||
TEST(RPCResponseTest, ErrorJsonRpcResponseTest) { | ||
ErrorJsonRpcResponse response(-32700,"Parse Error", "10"); | ||
EXPECT_EQ("{\"error\":{\"code\":-32700,\"data\":\"\",\"message\":\"Parse Error\"},\"id\":\"10\",\"jsonrpc\":\"2.0\"}", response.Serialize()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters