X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Frt_static_test.c;h=15c6deeed4e9e2464bfe14f69d0ab9daf24d9c9c;hb=fcea3951d44de0cc55d33c5e114487abe79d3406;hp=1647993a7d2697f12a5e6bc3e307a49da9802c38;hpb=6af063ee12dc292b7d37459199e2a51285030217;p=ric-plt%2Flib%2Frmr.git diff --git a/test/rt_static_test.c b/test/rt_static_test.c index 1647993..15c6dee 100644 --- a/test/rt_static_test.c +++ b/test/rt_static_test.c @@ -123,6 +123,7 @@ static int rt_test( ) { int enu = 0; int state; char *buf; + char *buf2; char* seed_fname; // seed file SOCKET_TYPE nn_sock; // differnt in each transport (nng == struct, SI/Nano == int) rmr_mbuf_t* mbuf; // message for meid route testing @@ -530,6 +531,36 @@ static int rt_test( ) { 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" );