X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fmbuf_api_static_test.c;h=d4eca07bd4e340f22065513ca14048097c843831;hb=316614a9808fcd107daa1b5ec190f6b2a9d804c3;hp=656287d6a3af99aecae5d251491aadbfb1c45852;hpb=d9de79acd9c205dc4f795e90a98331628ed6c85b;p=ric-plt%2Flib%2Frmr.git diff --git a/test/mbuf_api_static_test.c b/test/mbuf_api_static_test.c index 656287d..d4eca07 100644 --- a/test/mbuf_api_static_test.c +++ b/test/mbuf_api_static_test.c @@ -110,11 +110,19 @@ int mbuf_api_test( ) { errors += fail_if( i > 0, "(rv) attempt to copy bytes to meid with nil message" ); errno = 0; + strncpy( src_buf, "a very long string that should trigger an error when stuffing it into meid", sizeof( src_buf ) ); // ensure no zero byte at field length i = rmr_bytes2meid( mbuf, src_buf, RMR_MAX_MEID + 1 ); errors += fail_if( errno == 0, "(errno) attempt to copy bytes to meid with large source buffer" ); errors += fail_if( i != RMR_MAX_MEID, "(rv) attempt to copy bytes to meid with large source buffer" ); + + errno = 0; + i = rmr_bytes2meid( mbuf, src_buf, RMR_MAX_MEID ); // it's not 0 terminated at length expect failure + errors += fail_if( errno == 0, "(errno) attempt to copy non-zero termianted bytes to meid with large source buffer" ); + errors += fail_if( i != RMR_MAX_MEID, "(rv) attempt to copy bytes to meid with large source buffer" ); errno = 0; + memset( src_buf, 0, RMR_MAX_MEID+2 ); + strcpy( src_buf, "smaller bytes" ); i = rmr_bytes2meid( mbuf, src_buf, RMR_MAX_MEID ); errors += fail_if( errno != 0, "copy bytes to meid; expected errno to be ok" ); errors += fail_if( i != RMR_MAX_MEID, "copy bytes to meid; expected return value to be max meid len" );