File tree Expand file tree Collapse file tree 4 files changed +31
-21
lines changed
Expand file tree Collapse file tree 4 files changed +31
-21
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ set(TEST_TARGET ${CMAKE_PROJECT_NAME})
3333
3434set (TEST_SRCS
3535 src/RPC/test_RPCClient.cpp
36+ src/RPC/utils.cpp
3637)
3738
3839set (TEST_DUT_SRCS
Original file line number Diff line number Diff line change 77#include < catch.hpp>
88#include < StreamMock.h>
99#include < Arduino_RPClite.h>
10-
11- // Poor-man MsgPack encoder
12- #define ARRAY_N (x ) (0x90 + (x))
13- #define STRING_N (x ) (0xA0 + (x))
14- #define NIL 0xc0
15- #define FLOAT_32 0xcb
16- #define CALL_TAG 0x00
17- #define RESP_TAG 0x01
18-
19- // convert a byte array into an hex string
20- std::string to_hex_string (const unsigned char * data, size_t size) {
21- std::ostringstream oss;
22- oss << std::hex << std::setw (2 ) << std::setfill (' 0' );
23- for (size_t i = 0 ; i < size; ++i) {
24- oss << static_cast <int >(data[i]);
25- }
26- return oss.str ();
27- }
28-
29- #define COMPARE_ARRAYS (expected, got ) \
30- REQUIRE (to_hex_string(expected, sizeof (expected)) == to_hex_string(got, sizeof (expected)))
10+ #include " utils.h"
3111
3212TEST_CASE (" RPCClient::call" , " [RPCClient-01]" )
3313{
Original file line number Diff line number Diff line change 1+ #include < string>
2+ #include < sstream>
3+ #include < iomanip>
4+
5+ // convert a byte array into an hex string
6+ std::string to_hex_string (const unsigned char * data, size_t size) {
7+ std::ostringstream oss;
8+ oss << std::hex << std::setw (2 ) << std::setfill (' 0' );
9+ for (size_t i = 0 ; i < size; ++i) {
10+ oss << static_cast <int >(data[i]);
11+ }
12+ return oss.str ();
13+ }
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < string>
4+
5+ // Poor-man MsgPack encoder
6+ #define ARRAY_N (x ) (0x90 + (x))
7+ #define STRING_N (x ) (0xA0 + (x))
8+ #define NIL 0xc0
9+ #define FLOAT_32 0xcb
10+ #define CALL_TAG 0x00
11+ #define RESP_TAG 0x01
12+
13+ #define COMPARE_ARRAYS (expected, got ) \
14+ REQUIRE (to_hex_string(expected, sizeof (expected)) == to_hex_string(got, sizeof (expected)))
15+
16+ std::string to_hex_string(const unsigned char * data, size_t size);
You can’t perform that action at this time.
0 commit comments