1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into plugins

This commit is contained in:
James Booth 2014-01-30 23:50:54 +00:00
commit 4538f5c01a
4 changed files with 75 additions and 0 deletions

View File

@ -90,6 +90,7 @@ test_sources = \
tests/test_roster_list.c \
tests/test_preferences.c \
tests/test_server_events.c \
tests/test_muc.c \
tests/testsuite.c
main_source = src/main.c

58
tests/test_muc.c Normal file
View File

@ -0,0 +1,58 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include "muc.h"
void muc_before_test(void **state)
{
muc_init();
}
void muc_after_test(void **state)
{
muc_close();
}
void test_muc_add_invite(void **state)
{
char *room = "room@conf.server";
muc_add_invite(room);
gboolean invite_exists = muc_invites_include(room);
assert_true(invite_exists);
}
void test_muc_remove_invite(void **state)
{
char *room = "room@conf.server";
muc_add_invite(room);
muc_remove_invite(room);
gboolean invite_exists = muc_invites_include(room);
assert_false(invite_exists);
}
void test_muc_invite_count_0(void **state)
{
int invite_count = muc_invite_count();
assert_true(invite_count == 0);
}
void test_muc_invite_count_5(void **state)
{
muc_add_invite("room1@conf.server");
muc_add_invite("room2@conf.server");
muc_add_invite("room3@conf.server");
muc_add_invite("room4@conf.server");
muc_add_invite("room5@conf.server");
int invite_count = muc_invite_count();
assert_true(invite_count == 5);
}

7
tests/test_muc.h Normal file
View File

@ -0,0 +1,7 @@
void muc_before_test(void **state);
void muc_after_test(void **state);
void test_muc_add_invite(void **state);
void test_muc_remove_invite(void **state);
void test_muc_invite_count_0(void **state);
void test_muc_invite_count_5(void **state);

View File

@ -23,6 +23,7 @@
#include "test_preferences.h"
#include "test_server_events.h"
#include "test_cmd_alias.h"
#include "test_muc.h"
#define PROF_RUN_TESTS(name) fprintf(stderr, "\n-> Running %s\n", #name); \
fflush(stderr); \
@ -427,6 +428,13 @@ int main(int argc, char* argv[]) {
close_preferences),
};
const UnitTest muc_tests[] = {
unit_test_setup_teardown(test_muc_add_invite, muc_before_test, muc_after_test),
unit_test_setup_teardown(test_muc_remove_invite, muc_before_test, muc_after_test),
unit_test_setup_teardown(test_muc_invite_count_0, muc_before_test, muc_after_test),
unit_test_setup_teardown(test_muc_invite_count_5, muc_before_test, muc_after_test),
};
int bak, bak2, new;
fflush(stdout);
fflush(stderr);
@ -456,6 +464,7 @@ int main(int argc, char* argv[]) {
PROF_RUN_TESTS(preferences_tests);
PROF_RUN_TESTS(cmd_alias_tests);
PROF_RUN_TESTS(server_events_tests);
PROF_RUN_TESTS(muc_tests);
fflush(stdout);
dup2(bak, 1);