+ #ifdef NNG_UNDER_TEST
+ ep = NULL; // force to nil so we see it go non-nil
+ state = epsock_meid( ctx->rtable, mbuf, &nn_sock, &ep );
+ errors += fail_if_nil( ep, "ep was nil when looking up ep with known meid in message" );
+ errors += fail_not_equal( state, 1, "state was not true when looking up ep with known meid in message" );
+
+ rmr_str2meid( mbuf, "XXXmeid1" ); // id that we know is NOT in the map
+ state = epsock_meid( ctx->rtable, mbuf, &nn_sock, &ep );
+ // it is NOT a valid check to test ep for nil -- epsock_mied doesn't guarentee ep is set/cleared when state is false
+ errors += fail_not_equal( state, 0, "state was not false when looking up ep with unknown meid in message" );
+ #else
+ ep = NULL; // force to nil so we see it go non-nil
+ state = epsock_meid( ctx, ctx->rtable, mbuf, &nn_sock, &ep );
+ errors += fail_if_nil( ep, "ep was nil when looking up ep with known meid in message" );
+ errors += fail_not_equal( state, 1, "state was not true when looking up ep with known meid in message" );
+
+ state = epsock_meid( ctx, ctx->rtable, mbuf, &nn_sock, &ep ); // a second call to drive open == true check for coverage
+ errors += fail_if_nil( ep, "ep was nil when looking up ep with known meid in message; on open ep" );
+ errors += fail_not_equal( state, 1, "state was not true when looking up ep with known meid in message; on open ep" );
+
+ rmr_str2meid( mbuf, "XXXmeid1" ); // id that we know is NOT in the map
+ state = epsock_meid( ctx, ctx->rtable, mbuf, &nn_sock, &ep );
+ // it is NOT a valid check to test ep for nil -- epsock_mied doesn't guarentee ep is set/cleared when state is false
+ errors += fail_not_equal( state, 0, "state was not false when looking up ep with unknown meid in message" );
+
+ state = epsock_meid( NULL, ctx->rtable, mbuf, &nn_sock, &ep );
+ errors += fail_not_equal( state, 0, "epsock_meid returned true when given nil context" );
+
+ state = epsock_meid( ctx, ctx->rtable, mbuf, NULL, &ep );
+ errors += fail_not_equal( state, 0, "epsock_meid returned true when given nil socket pointer" );
+ #endif
+
+ // ------------ debugging and such; coverage only calls ----------------------------------------------------------
+ ep_stats( ctx->rtable, NULL, "name", NULL, NULL ); // ensure no crash when given nil pointer
+ rt_epcounts( ctx->rtable, "testing" );
+ rt_epcounts( NULL, "testing" );
+
+ buf = ensure_nlterm( NULL );
+ errors += fail_if_nil( buf, "ensure nlterm returned null pointer when given nil ptr" );
+ if( buf ) {
+ errors += fail_not_equal( strlen( buf ), 1, "ensure nlterm returned incorrect length string when given nil pointer" );
+ free( buf );
+ }
+
+ buf = ensure_nlterm( strdup( "x" ) ); // should return "x\n"
+ errors += fail_if_nil( buf, "ensure nlterm returned null pointer when given single char string" );
+ if( buf ) {
+ errors += fail_not_equal( strlen( buf ), 2, "ensure nlterm returned incorrect length string when given single char string" );
+ free( buf );
+ }
+
+ buf = strdup( "x\n" );
+ buf2 = ensure_nlterm( buf ); // buffer returned should be the same
+ if( fail_not_pequal( buf, buf2, "ensure nlterm returned new buffer for one char string with newline" ) ) {
+ errors++;
+ free( buf2 );
+ }
+ free( buf );
+
+ buf = strdup( "Missing our trips to Gloria's for papossas.\n" );
+ buf2 = ensure_nlterm( buf ); // buffer returned should be the same
+ if( fail_not_pequal( buf, buf2, "ensure nlterm returned new buffer for string with newline" ) ) {
+ errors++;
+ free( buf2 );
+ }
+ free( buf );
+
+ buf = ensure_nlterm( strdup( "Stand up and cheer!" ) ); // force addition of newline
+ if( buf ) {
+ errors += fail_not_equal( strcmp( buf, "Stand up and cheer!\n" ), 0, "ensure nlterm didn't add newline" );
+ free( buf );
+ buf = NULL;
+ }
+
+
+ // ------------- route manager request/response funcitons -------------------------------------------------------
+ {
+ rmr_mbuf_t* smsg;
+
+ smsg = rmr_alloc_msg( ctx, 1024 );
+ send_rt_ack( ctx, smsg, "123456", 0, "no reason" );
+
+ pctx = mk_dummy_ctx();
+ ctx->rtg_whid = -1;
+ state = send_update_req( pctx, ctx );
+ errors += fail_not_equal( state, 0, "send_update_req did not return 0" );
+
+ ctx->rtg_whid = rmr_wh_open( ctx, "localhost:19289" );
+ state = send_update_req( pctx, ctx );
+ errors += fail_if_equal( state, 0, "send_update_req to an open whid did not return 0" );
+ }
+
+
+ // ------------- si only; fd to ep conversion functions ---------------------------------------------------------
+ #ifndef NNG_UNDER_TEST
+ ep2 = (endpoint_t *) malloc( sizeof( *ep ) );
+
+ fd2ep_init( ctx );
+ fd2ep_add( ctx, 10, ep2 );
+
+ ep = fd2ep_get( ctx, 10 );
+ errors += fail_if_nil( ep, "fd2ep did not return pointer for known mapping" );
+ errors += fail_if_false( ep == ep2, "fd2ep did not return same pointer that was added" );
+
+ ep = fd2ep_get( ctx, 20 );
+ errors += fail_not_nil( ep, "fd2ep did returned a pointer for unknown mapping" );
+
+ ep = fd2ep_del( ctx, 10 );
+ errors += fail_if_nil( ep, "fd2ep delete did not return pointer for known mapping" );
+ errors += fail_if_false( ep == ep2, "fd2ep delete did not return same pointer that was added" );
+
+ ep = fd2ep_del( ctx, 20 );
+ errors += fail_not_nil( ep, "fd2ep delete returned a pointer for unknown mapping" );
+ #endif