diff options
author | Sam Spilsbury <smspillaz@gmail.com> | 2013-12-14 11:09:12 -0800 |
---|---|---|
committer | Philip Chimento <philip@endlessm.com> | 2014-01-15 18:24:45 -0200 |
commit | 0fcd808fc138d3f0cb7e0bdb40fbee1ae86aae43 (patch) | |
tree | f2a852e8f3c54c73e29f3567c25d46df78809678 /test/endless/test-hello.c | |
parent | 7844fc96bbf1d446923fc4e6cd1b3981104e6b0a (diff) |
Clean up the structure of the tests directory
Move all the tests for the SDK into tests/endless, move all
the demos into tests/demos, move all the smoke tests into
smoke-tests
[endlessm/eos-sdk#444]
Diffstat (limited to 'test/endless/test-hello.c')
-rw-r--r-- | test/endless/test-hello.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/endless/test-hello.c b/test/endless/test-hello.c new file mode 100644 index 0000000..687f14d --- /dev/null +++ b/test/endless/test-hello.c @@ -0,0 +1,59 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include <stdlib.h> +#include <glib.h> +#include <endless/endless.h> + +#include "run-tests.h" + +#define EXPECTED_HELLO_STRING "Hello, world!\n" + +static void +test_hello_stdout (void) +{ + GError *error = NULL; + + /* Unix-only test */ + if (g_test_trap_fork(0 /* timeout */, G_TEST_TRAP_SILENCE_STDOUT)) + { + gboolean success = eos_hello_sample_function (NULL, &error); + g_assert (success); + g_assert_no_error (error); + exit (0); + } + + g_test_trap_assert_passed (); + g_test_trap_assert_stdout (EXPECTED_HELLO_STRING); +} + +static void +test_hello_gfile (void) +{ + GError *error = NULL; + GFileIOStream *stream; + GFile *file = g_file_new_tmp ("sdktestXXXXXX", &stream, &error); + gboolean success; + char *file_contents; + + g_assert_no_error (error); + g_io_stream_close (G_IO_STREAM (stream), NULL, &error); + g_assert_no_error (error); + + success = eos_hello_sample_function (file, &error); + g_assert (success); + g_assert_no_error (error); + + g_file_load_contents (file, NULL, &file_contents, NULL, NULL, &error); + g_assert_no_error (error); + g_assert_cmpstr (file_contents, ==, EXPECTED_HELLO_STRING); + + g_free (file_contents); + g_object_unref (file); +} + +void +add_hello_tests (void) +{ + g_test_add_func ("/hello/stdout", test_hello_stdout); + g_test_add_func ("/hello/gfile", test_hello_gfile); +} |