增加tfe_stream类型转字符串的工具函数及对应单元测试用例
This commit is contained in:
33
common/test/test_addr.cpp
Normal file
33
common/test/test_addr.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
#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 192.168.100.100 10080 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();
|
||||
}
|
||||
Reference in New Issue
Block a user