summaryrefslogtreecommitdiff
path: root/test/http_gtest_main.cpp
blob: 5b7aee5616f7c8426b23966fc805788a63b64954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
}