add unittest for ranap_transp_layer_addr_decode()

The function ranap_transp_layer_addr_decode() lacks a unit test. Lets
add one.

Change-Id: I6d7427dc07c858a8dd76c1fb536ec3df3d96f1b1
This commit is contained in:
Philipp Maier 2022-01-10 13:11:19 +01:00 committed by laforge
parent 75f77e257a
commit 45631aa04f
2 changed files with 34 additions and 0 deletions

View File

@ -319,6 +319,34 @@ void test_ranap_new_transp_info_gtp(void)
OSMO_ASSERT(tli == NULL);
}
void test_ranap_transp_layer_addr_decode(void)
{
int rc;
char addr[100];
RANAP_TransportLayerAddress_t trasp_layer_addr = { 0 };
uint8_t encoded_addr_x213_nsap[] = {
0x35, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
uint8_t encoded_addr[] = { 0x01, 0x02, 0x03, 0x04 };
printf("Testing function ranap_transp_layer_addr_decode()\n");
printf(" ipv4, x213_nsap\n");
trasp_layer_addr.buf = encoded_addr_x213_nsap;
trasp_layer_addr.size = sizeof(encoded_addr_x213_nsap);
rc = ranap_transp_layer_addr_decode(addr, sizeof(addr), &trasp_layer_addr);
printf(" addr=%s\n", addr);
OSMO_ASSERT(rc == 0);
printf(" ipv4\n");
trasp_layer_addr.buf = encoded_addr;
trasp_layer_addr.size = sizeof(encoded_addr);
rc = ranap_transp_layer_addr_decode(addr, sizeof(addr), &trasp_layer_addr);
printf(" addr=%s\n", addr);
OSMO_ASSERT(rc == 0);
}
int main(int argc, char **argv)
{
asn1_xer_print = 0;
@ -331,6 +359,7 @@ int main(int argc, char **argv)
test_ranap_common();
test_ranap_new_transp_info_gtp();
test_ranap_new_transp_info_rtp();
test_ranap_transp_layer_addr_decode();
test_common_cleanup();
return 0;

View File

@ -51,3 +51,8 @@ Testing function ranap_new_transp_info_rtp()
transportLayerAddress = f11ff22ff33ff44ff55ff66ff77ff88f
bindingID = 11220000
unsupported address family
Testing function ranap_transp_layer_addr_decode()
ipv4, x213_nsap
addr=1.2.3.4
ipv4
addr=1.2.3.4