aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cplusplus_pair.cc35
1 files changed, 18 insertions, 17 deletions
diff --git a/tests/cplusplus_pair.cc b/tests/cplusplus_pair.cc
index 1148aaae..4481a4d7 100644
--- a/tests/cplusplus_pair.cc
+++ b/tests/cplusplus_pair.cc
@@ -7,10 +7,11 @@
// found online at https://opensource.org/licenses/MIT.
//
-#include "nng/nng.h"
-
#include <cstdio>
#include <cstring>
+#include <iostream>
+
+#include <nng/nng.h>
#define SOCKET_ADDRESS "inproc://c++"
@@ -22,58 +23,58 @@ main(int argc, char **argv)
nng_socket s1;
nng_socket s2;
- int rv;
+ nng_err rv;
size_t sz;
char buf[8];
(void) argc;
(void) argv;
nng_init(NULL);
- if ((rv = nng_pair1_open(&s1)) != 0) {
+ if ((rv = (nng_err) nng_pair1_open(&s1)) != 0) {
throw nng_strerror(rv);
}
- if ((rv = nng_pair1_open(&s2)) != 0) {
+ if ((rv = (nng_err) nng_pair1_open(&s2)) != 0) {
throw nng_strerror(rv);
}
- if ((rv = nng_listen(s1, SOCKET_ADDRESS, NULL, 0)) != 0) {
+ if ((rv = (nng_err) nng_listen(s1, SOCKET_ADDRESS, NULL, 0)) != 0) {
throw nng_strerror(rv);
}
- if ((rv = nng_dial(s2, SOCKET_ADDRESS, NULL, 0)) != 0) {
+ if ((rv = (nng_err) nng_dial(s2, SOCKET_ADDRESS, NULL, 0)) != 0) {
throw nng_strerror(rv);
}
- if ((rv = nng_send(s2, (void *) "ABC", 4, 0)) != 0) {
+ if ((rv = (nng_err) nng_send(s2, (void *) "ABC", 4, 0)) != 0) {
throw nng_strerror(rv);
}
sz = sizeof(buf);
- if ((rv = nng_recv(s1, buf, &sz, 0)) != 0) {
+ if ((rv = (nng_err) nng_recv(s1, buf, &sz, 0)) != 0) {
throw nng_strerror(rv);
}
- if ((sz != 4) || (memcmp(buf, "ABC", 4) != 0)) {
+ if ((sz != 4) || (std::strcmp(buf, "ABC") != 0)) {
throw "Contents did not match";
}
- if ((rv = nng_send(s1, (void *) "DEF", 4, 0)) != 0) {
+ if ((rv = (nng_err) nng_send(s1, (void *) "DEF", 4, 0)) != 0) {
throw nng_strerror(rv);
}
sz = sizeof(buf);
- if ((rv = nng_recv(s2, buf, &sz, 0)) != 0) {
+ if ((rv = (nng_err) nng_recv(s2, buf, &sz, 0)) != 0) {
throw nng_strerror(rv);
}
- if ((sz != 4) || (memcmp(buf, "DEF", 4) != 0)) {
+ if ((sz != 4) || (std::strcmp(buf, "DEF") != 0)) {
throw "Contents did not match";
}
- if ((rv = nng_socket_close(s1)) != 0) {
+ if ((rv = (nng_err) nng_socket_close(s1)) != 0) {
throw nng_strerror(rv);
}
- if ((rv = nng_socket_close(s2)) != 0) {
+ if ((rv = (nng_err) nng_socket_close(s2)) != 0) {
throw nng_strerror(rv);
}
- printf("Pass.\n");
+ std::cout << "Pass." << std::endl;
nng_fini();
#else
(void) argc;
(void) argv;
- printf("Skipped (protocol unconfigured).\n");
+ std::cout << "Skipped (protocol unconfigured)." << std::endl;
#endif
return (0);