Skip to content

Commit

Permalink
quality checks
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Jul 24, 2024
1 parent e1a35ef commit 852c2a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
11 changes: 4 additions & 7 deletions src/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,10 @@ SEXP rnng_send_aio(SEXP con, SEXP data, SEXP mode, SEXP timeout, SEXP clo) {
const SEXP ptrtag = NANO_TAG(con);
if ((sock = ptrtag == nano_SocketSymbol) || ptrtag == nano_ContextSymbol) {

switch (nano_encodes(mode)) {
case 1:
nano_serialize(&buf, data, NANO_PROT(con)); break;
case 2:
nano_encode(&buf, data); break;
default:
nano_serialize(&buf, data, NANO_PROT(con)); break;
if (nano_encodes(mode) == 2) {
nano_encode(&buf, data);
} else {
nano_serialize(&buf, data, NANO_PROT(con));
}

nng_msg *msg;
Expand Down
22 changes: 8 additions & 14 deletions src/comms.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,10 @@ SEXP rnng_send(SEXP con, SEXP data, SEXP mode, SEXP block) {
const SEXP ptrtag = NANO_TAG(con);
if (ptrtag == nano_SocketSymbol) {

switch (nano_encodes(mode)) {
case 1:
nano_serialize(&buf, data, NANO_PROT(con)); break;
case 2:
nano_encode(&buf, data); break;
default:
nano_serialize(&buf, data, NANO_PROT(con)); break;
if (nano_encodes(mode) == 2) {
nano_encode(&buf, data);
} else {
nano_serialize(&buf, data, NANO_PROT(con));
}

nng_socket *sock = (nng_socket *) NANO_PTR(con);
Expand Down Expand Up @@ -355,13 +352,10 @@ SEXP rnng_send(SEXP con, SEXP data, SEXP mode, SEXP block) {

} else if (ptrtag == nano_ContextSymbol) {

switch (nano_encodes(mode)) {
case 1:
nano_serialize(&buf, data, NANO_PROT(con)); break;
case 2:
nano_encode(&buf, data); break;
default:
nano_serialize(&buf, data, NANO_PROT(con)); break;
if (nano_encodes(mode) == 2) {
nano_encode(&buf, data);
} else {
nano_serialize(&buf, data, NANO_PROT(con));
}

nng_ctx *ctxp = (nng_ctx *) NANO_PTR(con);
Expand Down
8 changes: 5 additions & 3 deletions tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ nanotestaio(r <- recv_aio(rep, timeout = 500))
nanotestz(req$send("", block = 500))
p <- tryCatch(collect_pipe(r), error = function(e) NULL)
nanotestp(p)
if (!is.null(p)) nanotestnano(p)
nanotest(if (is.null(p)) TRUE else is_nano(p))
nanotest(.mark())
nanotestaio(r <- send_aio(rep, "", timeout = 500))
nanotesterr(collect_pipe(r), "valid")
Expand Down Expand Up @@ -308,8 +308,8 @@ nanotestxp(rep$dialer[[1L]])
nanotestz(close(ctx))
nanotestw(close(ctx) == 7L)
nanotestz(close(rep))
nanotest(reap(p) == 12L)
nanotestw(close(p) == 12L)
nanotest(if (is.null(p)) TRUE else reap(p) == 12L)
nanotestw(if (is.null(p)) TRUE else close(p) == 12L)

nanotestnano(pub <- nano("pub", listen = "inproc://ps"))
nanotestnano(sub <- nano("sub", dial = "inproc://ps", autostart = NA))
Expand Down Expand Up @@ -545,6 +545,8 @@ nanotesterr(close(fakedial), "valid Dialer")
fakelist <- `class<-`("test", "nanoListener")
nanotesterr(start(fakelist), "valid Listener")
nanotesterr(close(fakelist), "valid Listener")
fakepipe <- `class<-`("test", "nanoPipe")
nanotesterr(close(fakepipe), "valid Pipe")
unres <- `class<-`(NA, "unresolvedValue")
nanotest(!unresolved(unres))
nanotestp(unres)
Expand Down

0 comments on commit 852c2a0

Please sign in to comment.