diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-23 11:23:22 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-23 21:14:12 -0700 |
| commit | 8ad296769192cf4628710ac0b228be2aca6d8dad (patch) | |
| tree | edd6240a63cc3b2a7e6206e1cc07b5c5edb9f1bf /tests | |
| parent | 7074c5c50936308d1ef58be4ce1ca5e776e4c8cb (diff) | |
| download | nng-8ad296769192cf4628710ac0b228be2aca6d8dad.tar.gz nng-8ad296769192cf4628710ac0b228be2aca6d8dad.tar.bz2 nng-8ad296769192cf4628710ac0b228be2aca6d8dad.zip | |
Implement dynamic option numbering.
This permits option numbers to be allocated based on string name.
Eventually all the option values will be replaced with option
names. This will facilitate transports (ZeroTier) that may need
further options.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/pair1.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/tests/pair1.c b/tests/pair1.c index d160acdd..adb50c88 100644 --- a/tests/pair1.c +++ b/tests/pair1.c @@ -106,8 +106,13 @@ TestMain("PAIRv1 protocol", { int rv; int i; nng_msg *msg; + int poly; - So(nng_setopt_int(s1, NNG_OPT_POLYAMOROUS, 1) == 0); + poly = nng_option_lookup("polyamorous"); + So(poly >= 0); + So(nng_option_name(poly) != NULL); + So(strcmp(nng_option_name(poly), "polyamorous") == 0); + So(nng_setopt_int(s1, poly, 1) == 0); So(nng_setopt_int(s1, NNG_OPT_RCVBUF, 1) == 0); So(nng_setopt_int(s1, NNG_OPT_SNDBUF, 1) == 0); @@ -155,14 +160,16 @@ TestMain("PAIRv1 protocol", { }); Convey("Cannot set polyamorous mode after connect", { + int poly; So(nng_listen(s1, addr, NULL, 0) == 0); So(nng_dial(c1, addr, NULL, 0) == 0); nng_usleep(100000); + poly = nng_option_lookup("polyamorous"); + So(poly >= 0); + So(nng_option_name(poly) != NULL); + So(strcmp(nng_option_name(poly), "polyamorous") == 0); - So(nng_setopt_int(s1, NNG_OPT_POLYAMOROUS, 1) == - NNG_ESTATE); - So(nng_setopt_int(c1, NNG_OPT_POLYAMOROUS, 1) == - NNG_ESTATE); + So(nng_setopt_int(s1, poly, 1) == NNG_ESTATE); }); Convey("Monogamous raw mode works", { @@ -329,12 +336,18 @@ TestMain("PAIRv1 protocol", { int v; nng_pipe p1; nng_pipe p2; + int poly; - So(nng_getopt_int(s1, NNG_OPT_POLYAMOROUS, &v) == 0); + poly = nng_option_lookup("polyamorous"); + So(poly >= 0); + So(nng_option_name(poly) != NULL); + So(strcmp(nng_option_name(poly), "polyamorous") == 0); + + So(nng_getopt_int(s1, poly, &v) == 0); So(v == 0); - So(nng_setopt_int(s1, NNG_OPT_POLYAMOROUS, 1) == 0); - So(nng_getopt_int(s1, NNG_OPT_POLYAMOROUS, &v) == 0); + So(nng_setopt_int(s1, poly, 1) == 0); + So(nng_getopt_int(s1, poly, &v) == 0); So(v == 1); So(nng_listen(s1, addr, NULL, 0) == 0); @@ -389,8 +402,14 @@ TestMain("PAIRv1 protocol", { Convey("Polyamorous default works", { nng_msg *msg; + int poly; + + poly = nng_option_lookup("polyamorous"); + So(poly >= 0); + So(nng_option_name(poly) != NULL); + So(strcmp(nng_option_name(poly), "polyamorous") == 0); - So(nng_setopt_int(s1, NNG_OPT_POLYAMOROUS, 1) == 0); + So(nng_setopt_int(s1, poly, 1) == 0); So(nng_listen(s1, addr, NULL, 0) == 0); So(nng_dial(c1, addr, NULL, 0) == 0); @@ -421,12 +440,18 @@ TestMain("PAIRv1 protocol", { uint32_t hops; nng_pipe p1; nng_pipe p2; + int poly; + + poly = nng_option_lookup("polyamorous"); + So(poly >= 0); + So(nng_option_name(poly) != NULL); + So(strcmp(nng_option_name(poly), "polyamorous") == 0); - So(nng_getopt_int(s1, NNG_OPT_POLYAMOROUS, &v) == 0); + So(nng_getopt_int(s1, poly, &v) == 0); So(v == 0); - So(nng_setopt_int(s1, NNG_OPT_POLYAMOROUS, 1) == 0); - So(nng_getopt_int(s1, NNG_OPT_POLYAMOROUS, &v) == 0); + So(nng_setopt_int(s1, poly, 1) == 0); + So(nng_getopt_int(s1, poly, &v) == 0); So(v == 1); v = 0; |
