diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-09-25 12:49:10 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-09-27 14:38:12 -0700 |
| commit | 64db0f085be0c9efc6dca8d9e72d3e5a47cb792e (patch) | |
| tree | 475520498d8ebe9e47e9785d8f9d209c87582400 /tests/reqrep.c | |
| parent | 86a96e5bf1b207a8b1aa925e1d9f73ce834505b8 (diff) | |
| download | nng-64db0f085be0c9efc6dca8d9e72d3e5a47cb792e.tar.gz nng-64db0f085be0c9efc6dca8d9e72d3e5a47cb792e.tar.bz2 nng-64db0f085be0c9efc6dca8d9e72d3e5a47cb792e.zip | |
Refactor option handling APIs.
This makes the APIs use string keys, and largely eliminates the use of
integer option IDs altogether. The underlying registration for options
is also now a bit richer, letting protcols and transports declare the
actual options they use, rather than calling down into each entry point
carte blanche and relying on ENOTSUP.
This code may not be as fast as the integers was, but it is more intuitive,
easier to extend, and is not on any hot code paths. (If you're diddling
options on a hot code path you're doing something wrong.)
Diffstat (limited to 'tests/reqrep.c')
| -rw-r--r-- | tests/reqrep.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/tests/reqrep.c b/tests/reqrep.c index 537d45c8..c31f0212 100644 --- a/tests/reqrep.c +++ b/tests/reqrep.c @@ -13,9 +13,6 @@ #include <string.h> -extern const char *nng_opt_req_resendtime; -extern int nng_optid_req_resendtime; - TestMain("REQ/REP pattern", { int rv; const char *addr = "inproc://test"; @@ -32,19 +29,13 @@ TestMain("REQ/REP pattern", { }); Convey("Resend time option id works", { - int opt; - const char *name; - opt = nng_option_lookup(nng_opt_req_resendtime); - So(opt >= 0); - So(opt == nng_optid_req_resendtime); - name = nng_option_name(opt); - So(name != NULL); - So(strcmp(name, nng_opt_req_resendtime) == 0); // Set timeout. - So(nng_setopt_usec(req, opt, 10000) == 0); + So(nng_setopt_usec( + req, NNG_OPT_REQ_RESENDTIME, 10000) == 0); // Check invalid size - So(nng_setopt(req, opt, name, 1) == NNG_EINVAL); + So(nng_setopt(req, NNG_OPT_REQ_RESENDTIME, "", 1) == + NNG_EINVAL); }); Convey("Recv with no send fails", { @@ -75,8 +66,8 @@ TestMain("REQ/REP pattern", { }); Convey("Cannot set resend time", { - So(nng_setopt_usec(rep, nng_optid_req_resendtime, - 100) == NNG_ENOTSUP); + So(nng_setopt_usec(rep, NNG_OPT_REQ_RESENDTIME, 100) == + NNG_ENOTSUP); }); }); @@ -140,8 +131,8 @@ TestMain("REQ/REP pattern", { nng_close(req); }); - So(nng_setopt_usec(req, nng_optid_req_resendtime, retry) == 0); - So(nng_setopt_int(req, nng_optid_sendbuf, 16) == 0); + So(nng_setopt_usec(req, NNG_OPT_REQ_RESENDTIME, retry) == 0); + So(nng_setopt_int(req, NNG_OPT_SENDBUF, 16) == 0); So(nng_msg_alloc(&abc, 0) == 0); So(nng_msg_append(abc, "abc", 4) == 0); |
