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/survey.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/survey.c')
| -rw-r--r-- | tests/survey.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/tests/survey.c b/tests/survey.c index ae252cd5..346f2f30 100644 --- a/tests/survey.c +++ b/tests/survey.c @@ -14,7 +14,6 @@ #include <string.h> extern const char *nng_opt_surveyor_surveytime; -extern int nng_optid_surveyor_surveytime; #define APPENDSTR(m, s) nng_msg_append(m, s, strlen(s)) #define CHECKSTR(m, s) \ @@ -33,17 +32,6 @@ TestMain("SURVEY pattern", { Reset({ nng_close(surv); }); - Convey("Surveytime option id works", { - int opt; - const char *name; - opt = nng_option_lookup(nng_opt_surveyor_surveytime); - So(opt >= 0); - So(opt == nng_optid_surveyor_surveytime); - name = nng_option_name(opt); - So(name != NULL); - So(strcmp(name, nng_opt_surveyor_surveytime) == 0); - }); - Convey("Protocols match", { So(nng_protocol(surv) == NNG_PROTO_SURVEYOR); So(nng_peer(surv) == NNG_PROTO_RESPONDENT); @@ -57,8 +45,8 @@ TestMain("SURVEY pattern", { Convey("Survey without responder times out", { nng_msg *msg; - So(nng_setopt_usec(surv, nng_optid_surveyor_surveytime, - 50000) == 0); + So(nng_setopt_usec( + surv, nng_opt_surveyor_surveytime, 50000) == 0); So(nng_msg_alloc(&msg, 0) == 0); So(nng_sendmsg(surv, msg, 0) == 0); So(nng_recvmsg(surv, &msg, 0) == NNG_ETIMEDOUT); @@ -97,8 +85,8 @@ TestMain("SURVEY pattern", { nng_close(resp); }); - So(nng_setopt_usec( - surv, nng_optid_surveyor_surveytime, 50000) == 0); + So(nng_setopt_usec(surv, nng_opt_surveyor_surveytime, 50000) == + 0); So(nng_listen(surv, addr, NULL, 0) == 0); So(nng_dial(resp, addr, NULL, 0) == 0); @@ -132,8 +120,8 @@ TestMain("SURVEY pattern", { Convey("And goes to non-survey state", { rtimeo = 200000; - So(nng_setopt_usec(surv, nng_optid_recvtimeo, - 200000) == 0); + So(nng_setopt_usec( + surv, NNG_OPT_RECVTIMEO, 200000) == 0); So(nng_recvmsg(surv, &msg, 0) == NNG_ESTATE); }); }); |
