Skip to content

Commit

Permalink
Added rpcCall tests, fixed template recursion bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfjlaros committed Dec 20, 2018
1 parent 7c292b9 commit 5a607eb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions simpleRPC/rpcCall.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
#include "tuple.tcc"


/*
* Prototypes needed for recursive definitions.
*/
template<class... Tail, class F, class... Args>
void _call(void (*)(char *, Tail...), F, Args...);
template<class... Tail, class F, class... Args>
void _call(void (*)(const char *, Tail...), F, Args...);


/**
* Write a return value to serial.
*
Expand Down
28 changes: 28 additions & 0 deletions tests/test_rpcCall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ TEST_CASE("RPC call function", "[call]") {
static short int g(int, char) {
return 0;
}
static void h(int, char *) {}
static void i(int, const char *) {}
static void j(char *, int) {}
static void k(const char *, int) {}
};

Serial.reset();
Expand All @@ -22,6 +26,30 @@ TEST_CASE("RPC call function", "[call]") {

REQUIRE(Serial.rx == sizeof(int) + sizeof(char));
REQUIRE(Serial.tx == sizeof(short int));

Serial.reset();
rpcCall(S::h);

REQUIRE(Serial.rx == sizeof(int) + 3);
REQUIRE(Serial.tx == 0);

Serial.reset();
rpcCall(S::i);

REQUIRE(Serial.rx == sizeof(int) + 3);
REQUIRE(Serial.tx == 0);

Serial.reset();
rpcCall(S::j);

REQUIRE(Serial.rx == sizeof(int) + 3);
REQUIRE(Serial.tx == 0);

Serial.reset();
rpcCall(S::k);

REQUIRE(Serial.rx == sizeof(int) + 3);
REQUIRE(Serial.tx == 0);
}

TEST_CASE("RPC call class member functions", "[call]") {
Expand Down

0 comments on commit 5a607eb

Please sign in to comment.