tests: remove dependency on check package
Only check_parser depends on the check. Convert it. All tests will be rewritten at once when new testsuite is implemented.
This commit is contained in:
@@ -10,27 +10,34 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include <strophe.h>
|
||||
#include "strophe.h"
|
||||
#include "parser.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
START_TEST(create_destroy)
|
||||
#define fail_unless(expr) do { \
|
||||
int result = (expr); \
|
||||
if (!result) { \
|
||||
printf("%s:%d: Assertion failed: %s\n", \
|
||||
__FILE__, __LINE__, #expr); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static void create_destroy(void)
|
||||
{
|
||||
xmpp_ctx_t *ctx;
|
||||
parser_t *parser;
|
||||
|
||||
ctx = xmpp_ctx_new(NULL, NULL);
|
||||
parser = parser_new(ctx, NULL, NULL, NULL, NULL);
|
||||
fail_unless(parser != NULL, "Parser creation failed.");
|
||||
fail_unless(parser != NULL);
|
||||
parser_free(parser);
|
||||
xmpp_ctx_free(ctx);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
int cbtest_got_start = 0;
|
||||
void cbtest_handle_start(char *name, char **attrs, void *userdata)
|
||||
@@ -53,7 +60,7 @@ void cbtest_handle_stanza(xmpp_stanza_t *stanza, void *userdata)
|
||||
cbtest_got_stanza = 1;
|
||||
}
|
||||
|
||||
START_TEST(callbacks)
|
||||
static void callbacks(void)
|
||||
{
|
||||
xmpp_ctx_t *ctx;
|
||||
parser_t *parser;
|
||||
@@ -79,16 +86,18 @@ START_TEST(callbacks)
|
||||
parser_free(parser);
|
||||
xmpp_ctx_free(ctx);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite *parser_suite(void)
|
||||
int main()
|
||||
{
|
||||
Suite *s = suite_create("Parser");
|
||||
TCase *tc_core = tcase_create("Core");
|
||||
tcase_add_test(tc_core, create_destroy);
|
||||
tcase_add_test(tc_core, callbacks);
|
||||
suite_add_tcase(s, tc_core);
|
||||
return s;
|
||||
}
|
||||
printf("XML parser tests.\n");
|
||||
|
||||
TEST_MAIN
|
||||
printf("create-destroy: ");
|
||||
create_destroy();
|
||||
printf("ok\n");
|
||||
|
||||
printf("callbacks: ");
|
||||
callbacks();
|
||||
printf("ok\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user