diff options
| author | 李佳 <[email protected]> | 2024-04-12 11:41:14 +0000 |
|---|---|---|
| committer | 李佳 <[email protected]> | 2024-04-12 11:41:14 +0000 |
| commit | f40db506ee7570e836ac97b7806a679bc36da155 (patch) | |
| tree | e4483ca1d2a28079c57ab6f0ac055dfe08c47915 /test/http_decoder_stub.cpp | |
| parent | 55ac6e270ae37299e2bce3a47a3d784e29dcae14 (diff) | |
| parent | 094d0f8e45931b195e358989d2843a298e9fd567 (diff) | |
Merge branch 'api-unit-test' into 'develop'
Add unit tests.
See merge request stellar/http_decoder!5
Diffstat (limited to 'test/http_decoder_stub.cpp')
| -rw-r--r-- | test/http_decoder_stub.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/test/http_decoder_stub.cpp b/test/http_decoder_stub.cpp index 77a1483..e719ebe 100644 --- a/test/http_decoder_stub.cpp +++ b/test/http_decoder_stub.cpp @@ -8,6 +8,8 @@ #include <string.h> #include "http_decoder.h" + + #ifdef __cplusplus extern "C" { @@ -18,12 +20,13 @@ extern "C" #include "stellar.h" #include "http_decoder_gtest.h" #include "MESA_jump_layer.h" +extern struct fake_stellar *g_fake_stellar; static int g_topic_id = -1; static msg_free_cb_func *g_msg_free_cb = NULL; static void *g_msg_free_cb_arg = NULL; - - extern struct fake_stellar *g_fake_stellar; + static on_msg_cb_func *g_topic_sub_cb = NULL; + static void *g_topic_sub_cb_arg = NULL; int commit_test_result_json(cJSON *node, const char *name) { @@ -185,8 +188,7 @@ extern "C" extern int http_decoder_test_entry(struct session *sess, int topic_id, const void *data, void *cb_arg); int session_mq_publish_message(struct session *sess, int topic_id, void *data) { - http_decoder_test_entry(sess, topic_id, data, NULL); - + g_topic_sub_cb(sess, topic_id, data, g_topic_sub_cb_arg); g_msg_free_cb(data, g_msg_free_cb_arg); return 0; } @@ -217,7 +219,7 @@ extern "C" } int submit_len = MIN(fses->tcp_mss, fpkt->payload_data_len - fpkt->payload_submit_offset); - if(submit_len <= 0) + if (submit_len <= 0) { *payload_len = 0; return NULL; @@ -241,7 +243,9 @@ extern "C" int session_mq_subscribe_topic(struct stellar *st, int topic_id, on_msg_cb_func *sub_cb, void *cb_arg) { - // to do + //todo, support multiple topic? + g_topic_sub_cb = sub_cb; + g_topic_sub_cb_arg = cb_arg; return 0; } |
