Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
avbelov23 committed Oct 8, 2020
1 parent d033f8c commit 24080c6
Showing 1 changed file with 14 additions and 29 deletions.
43 changes: 14 additions & 29 deletions tempesta_fw/t/unit/test_hpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,19 @@ TEST(hpack, enc_table_rbtree)
#undef HDR_VALUE_5
}

#define ADD_NODE(s, n) \
do { \
res = tfw_hpack_rbtree_find(tbl, s, &n, &pl); \
EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); \
EXPECT_NULL(n); \
EXPECT_OK(tfw_hpack_add_node(tbl, s, &pl, TFW_H2_TRANS_INPLACE)); \
bzero_fast(&pl, sizeof(pl)); \
res = tfw_hpack_rbtree_find(tbl, s, &n, &pl); \
EXPECT_EQ(res, HPACK_IDX_ST_FOUND); \
EXPECT_NULL(pl.parent); \
EXPECT_NOT_NULL(n); \
} while (0)

TEST(hpack, rbtree_ins_rebalance)
{
TfwHPackETbl *tbl;
Expand Down Expand Up @@ -1955,19 +1968,6 @@ TEST(hpack, rbtree_ins_rebalance)

tbl = &ctx.hpack.enc_tbl;

#define ADD_NODE(s, n) \
do { \
res = tfw_hpack_rbtree_find(tbl, s, &n, &pl); \
EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); \
EXPECT_NULL(n); \
EXPECT_OK(tfw_hpack_add_node(tbl, s, &pl, TFW_H2_TRANS_INPLACE)); \
bzero_fast(&pl, sizeof(pl)); \
res = tfw_hpack_rbtree_find(tbl, s, &n, &pl); \
EXPECT_EQ(res, HPACK_IDX_ST_FOUND); \
EXPECT_NULL(pl.parent); \
EXPECT_NOT_NULL(n); \
} while (0)

ADD_NODE(s1, n1);
ADD_NODE(s2, n2);
ADD_NODE(s3, n3);
Expand Down Expand Up @@ -2068,8 +2068,6 @@ do { \
EXPECT_EQ(HPACK_NODE_COND(tbl, n2->right), n1);
EXPECT_NULL(HPACK_NODE_COND(tbl, n1->left));
EXPECT_NULL(HPACK_NODE_COND(tbl, n1->right));

#undef ADD_NODE
}

TEST(hpack, rbtree_del_rebalance)
Expand Down Expand Up @@ -2126,19 +2124,6 @@ TEST(hpack, rbtree_del_rebalance)

tbl = &ctx.hpack.enc_tbl;

#define ADD_NODE(s, n) \
do { \
res = tfw_hpack_rbtree_find(tbl, s, &n, &pl); \
EXPECT_EQ(res, HPACK_IDX_ST_NOT_FOUND); \
EXPECT_NULL(n); \
EXPECT_OK(tfw_hpack_add_node(tbl, s, &pl, TFW_H2_TRANS_INPLACE)); \
bzero_fast(&pl, sizeof(pl)); \
res = tfw_hpack_rbtree_find(tbl, s, &n, &pl); \
EXPECT_EQ(res, HPACK_IDX_ST_FOUND); \
EXPECT_NULL(pl.parent); \
EXPECT_NOT_NULL(n); \
} while (0)

ADD_NODE(s1, n1);
ADD_NODE(s2, n2);
ADD_NODE(s3, n3);
Expand Down Expand Up @@ -2240,9 +2225,9 @@ do { \
EXPECT_EQ(HPACK_NODE_COND(tbl, n9->right), n10);
EXPECT_NULL(HPACK_NODE_COND(tbl, n10->left));
EXPECT_NULL(HPACK_NODE_COND(tbl, n10->right));
}

#undef ADD_NODE
}

TEST_SUITE(hpack)
{
Expand Down

0 comments on commit 24080c6

Please sign in to comment.