summaryrefslogtreecommitdiff
path: root/test/http_gtest_main.cpp
diff options
context:
space:
mode:
author李佳 <[email protected]>2024-04-12 11:41:14 +0000
committer李佳 <[email protected]>2024-04-12 11:41:14 +0000
commitf40db506ee7570e836ac97b7806a679bc36da155 (patch)
treee4483ca1d2a28079c57ab6f0ac055dfe08c47915 /test/http_gtest_main.cpp
parent55ac6e270ae37299e2bce3a47a3d784e29dcae14 (diff)
parent094d0f8e45931b195e358989d2843a298e9fd567 (diff)
Merge branch 'api-unit-test' into 'develop'
Add unit tests. See merge request stellar/http_decoder!5
Diffstat (limited to 'test/http_gtest_main.cpp')
-rw-r--r--test/http_gtest_main.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/http_gtest_main.cpp b/test/http_gtest_main.cpp
new file mode 100644
index 0000000..5b7aee5
--- /dev/null
+++ b/test/http_gtest_main.cpp
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <assert.h>
+#include <getopt.h>
+#include <gtest/gtest.h>
+#include "http_decoder_gtest.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+struct fake_stellar *g_fake_stellar; //export symbol for commit_test_result_json()
+extern int http_decoder_entry(struct session *sess, int events,const struct packet *pkt, void *cb_arg);
+extern int http_decoder_test_entry(struct session *sess, int topic_id, const void *data, void *cb_arg);
+extern void *http_decoder_init(struct stellar *st);
+extern void *http_decoder_test_init(struct stellar *st);
+}
+#endif
+
+TEST(HTTP_DECODER, GTEST)
+{
+ ASSERT_EQ(0, hdgt_compare_result(g_fake_stellar));
+}
+
+int main(int argc, char **argv)
+{
+ g_fake_stellar = hdgt_create();
+
+ if(hdgt_init_once(g_fake_stellar, argc, argv, http_decoder_init, http_decoder_entry, http_decoder_test_init, http_decoder_test_entry) < 0)
+ {
+ fprintf(stderr, "hdgt_init_once() fail!\n");
+ exit(1);
+ }
+
+ hdgt_main_loop(g_fake_stellar);
+
+ ::testing::InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
+
+ hdgt_destroy(g_fake_stellar);
+
+ return ret;
+} \ No newline at end of file