From 879b7c1ee23770ecbb19da425ab4387eeff51abc Mon Sep 17 00:00:00 2001 From: Artyom Belov Date: Thu, 8 Oct 2020 16:27:03 +0300 Subject: [PATCH] refactoring --- tempesta_fw/t/unit/test_hpack.c | 43 +++++++++++---------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/tempesta_fw/t/unit/test_hpack.c b/tempesta_fw/t/unit/test_hpack.c index de07b6d7e..ffc1af6aa 100644 --- a/tempesta_fw/t/unit/test_hpack.c +++ b/tempesta_fw/t/unit/test_hpack.c @@ -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; @@ -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); @@ -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) @@ -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); @@ -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) {