From 272e9f83fc97141a19af5db447481f37e587cfb3 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 29 May 2015 01:22:24 +0100 Subject: [PATCH] Added priority tests --- functionaltests/functionaltests.c | 6 ++ functionaltests/test_presence.c | 129 ++++++++++++++++++++---------- functionaltests/test_presence.h | 2 + 3 files changed, 94 insertions(+), 43 deletions(-) diff --git a/functionaltests/functionaltests.c b/functionaltests/functionaltests.c index 1b84a73f..e0a4415a 100644 --- a/functionaltests/functionaltests.c +++ b/functionaltests/functionaltests.c @@ -79,6 +79,12 @@ int main(int argc, char* argv[]) { unit_test_setup_teardown(presence_chat_with_message, init_prof_test, close_prof_test), + unit_test_setup_teardown(presence_set_priority, + init_prof_test, + close_prof_test), + unit_test_setup_teardown(presence_includes_priority, + init_prof_test, + close_prof_test), }; return run_tests(all_tests); diff --git a/functionaltests/test_presence.c b/functionaltests/test_presence.c index 90ebff2b..210cdaaf 100644 --- a/functionaltests/test_presence.c +++ b/functionaltests/test_presence.c @@ -19,9 +19,9 @@ presence_online(void **state) prof_input("/online"); assert_true(stbbr_received( - "" - "" - "" + "" + "" + "" )); assert_true(prof_output_exact("Status set to online (priority 0)")); @@ -35,10 +35,10 @@ presence_online_with_message(void **state) prof_input("/online \"Hi there\""); assert_true(stbbr_received( - "" - "Hi there" - "" - "" + "" + "Hi there" + "" + "" )); assert_true(prof_output_exact("Status set to online (priority 0), \"Hi there\".")); @@ -52,10 +52,10 @@ presence_away(void **state) prof_input("/away"); assert_true(stbbr_received( - "" - "away" - "" - "" + "" + "away" + "" + "" )); assert_true(prof_output_exact("Status set to away (priority 0)")); @@ -69,11 +69,11 @@ presence_away_with_message(void **state) prof_input("/away \"I'm not here for a bit\""); assert_true(stbbr_received( - "" - "away" - "I'm not here for a bit" - "" - "" + "" + "away" + "I'm not here for a bit" + "" + "" )); assert_true(prof_output_exact("Status set to away (priority 0), \"I'm not here for a bit\".")); @@ -87,10 +87,10 @@ presence_xa(void **state) prof_input("/xa"); assert_true(stbbr_received( - "" - "xa" - "" - "" + "" + "xa" + "" + "" )); assert_true(prof_output_exact("Status set to xa (priority 0)")); @@ -104,11 +104,11 @@ presence_xa_with_message(void **state) prof_input("/xa \"Gone to the shops\""); assert_true(stbbr_received( - "" - "xa" - "Gone to the shops" - "" - "" + "" + "xa" + "Gone to the shops" + "" + "" )); assert_true(prof_output_exact("Status set to xa (priority 0), \"Gone to the shops\".")); @@ -122,10 +122,10 @@ presence_dnd(void **state) prof_input("/dnd"); assert_true(stbbr_received( - "" - "dnd" - "" - "" + "" + "dnd" + "" + "" )); assert_true(prof_output_exact("Status set to dnd (priority 0)")); @@ -139,11 +139,11 @@ presence_dnd_with_message(void **state) prof_input("/dnd \"Working\""); assert_true(stbbr_received( - "" - "dnd" - "Working" - "" - "" + "" + "dnd" + "Working" + "" + "" )); assert_true(prof_output_exact("Status set to dnd (priority 0), \"Working\".")); @@ -157,10 +157,10 @@ presence_chat(void **state) prof_input("/chat"); assert_true(stbbr_received( - "" - "chat" - "" - "" + "" + "chat" + "" + "" )); assert_true(prof_output_exact("Status set to chat (priority 0)")); @@ -174,12 +174,55 @@ presence_chat_with_message(void **state) prof_input("/chat \"Free to talk\""); assert_true(stbbr_received( - "" - "chat" - "Free to talk" - "" - "" + "" + "chat" + "Free to talk" + "" + "" )); assert_true(prof_output_exact("Status set to chat (priority 0), \"Free to talk\".")); } + +void +presence_set_priority(void **state) +{ + prof_connect("stabber@localhost", "password"); + + prof_input("/priority 25"); + + assert_true(stbbr_received( + "" + "25" + "" + "" + )); + + assert_true(prof_output_exact("Priority set to 25.")); +} + +void +presence_includes_priority(void **state) +{ + prof_connect("stabber@localhost", "password"); + + prof_input("/priority 25"); + assert_true(stbbr_received( + "" + "25" + "" + "" + )); + assert_true(prof_output_exact("Priority set to 25.")); + + prof_input("/chat \"Free to talk\""); + assert_true(stbbr_received( + "" + "25" + "chat" + "Free to talk" + "" + "" + )); + assert_true(prof_output_exact("Status set to chat (priority 25), \"Free to talk\".")); +} diff --git a/functionaltests/test_presence.h b/functionaltests/test_presence.h index 2e57c107..23fd5d98 100644 --- a/functionaltests/test_presence.h +++ b/functionaltests/test_presence.h @@ -8,3 +8,5 @@ void presence_dnd(void **state); void presence_dnd_with_message(void **state); void presence_chat(void **state); void presence_chat_with_message(void **state); +void presence_set_priority(void **state); +void presence_includes_priority(void **state);