diff options
author | James Booth <boothj5@gmail.com> | 2015-05-27 01:06:17 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-05-27 01:06:17 +0100 |
commit | db9376d82bcb71caae627b05f79849369798aa2f (patch) | |
tree | 65cacd56523151d6ea81813fba0bb9e186b19501 /stabbertests/proftest.c | |
parent | 7507e4ecfad65e1df0ac60d56599aeea6027e345 (diff) | |
download | profani-tty-db9376d82bcb71caae627b05f79849369798aa2f.tar.gz |
Simplified expect tests
Diffstat (limited to 'stabbertests/proftest.c')
-rw-r--r-- | stabbertests/proftest.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/stabbertests/proftest.c b/stabbertests/proftest.c index 65cee269..3b3014ad 100644 --- a/stabbertests/proftest.c +++ b/stabbertests/proftest.c @@ -20,6 +20,8 @@ char *config_orig; char *data_orig; +int fd = 0; + gboolean _create_dir(char *name) { @@ -141,6 +143,8 @@ init_prof_test(void **state) _create_data_dir(); _create_chatlogs_dir(); _create_logs_dir(); + + prof_start(); } void @@ -153,3 +157,31 @@ close_prof_test(void **state) stbbr_stop(); } + +void +prof_start(void) +{ + fd = exp_spawnl("./profanity", NULL); + FILE *fp = fdopen(fd, "r+"); + + if (fp == NULL) { + assert_true(FALSE); + } + + setbuf(fp, (char *)0); +} + +void +prof_input(char *input) +{ + GString *inp_str = g_string_new(input); + g_string_append(inp_str, "\r"); + write(fd, inp_str->str, inp_str->len); + g_string_free(inp_str, TRUE); +} + +int +prof_output(char *text) +{ + return (1 == exp_expectl(fd, exp_exact, text, 1, exp_end)); +} |