34 lines
927 B
C++
34 lines
927 B
C++
|
|
#include <gtest/gtest.h>
|
|
#include <tfe_types.h>
|
|
#include <stdlib.h>
|
|
|
|
TEST(TfeStreamAddrToStr, StreamTuple4)
|
|
{
|
|
auto * __stream_addr = (struct tfe_stream_addr *) malloc(sizeof(struct tfe_stream_addr) +
|
|
sizeof(struct tfe_stream_addr_tuple4_v4));
|
|
|
|
struct tfe_stream_addr_ipv4 * st_addr_v4 = __stream_addr->ipv4;
|
|
__stream_addr->addrtype = TFE_ADDR_STREAM_TUPLE4_V4;
|
|
__stream_addr->addrlen = sizeof(struct tfe_stream_addr_tuple4_v4);
|
|
|
|
/* 192.168.100.50 192.168.100.100 10080 80 */
|
|
st_addr_v4->saddr.s_addr = 0x3264a8c0;
|
|
st_addr_v4->source = 24615;
|
|
st_addr_v4->daddr.s_addr = 0x6464a8c0;
|
|
st_addr_v4->dest = 20480;
|
|
|
|
const char * __sample = "192.168.100.50 10080 192.168.100.100 80";
|
|
char * __result = tfe_stream_addr_to_str(__stream_addr);
|
|
|
|
EXPECT_STREQ(__sample, __result);
|
|
free(__result);
|
|
free(__stream_addr);
|
|
}
|
|
|
|
int main(int argc, char ** argv)
|
|
{
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|