soylent r151 - trunk/libsoylent/test
- From: svenp svn gnome org
- To: svn-commits-list gnome org
- Subject: soylent r151 - trunk/libsoylent/test
- Date: Sun, 8 Jun 2008 11:34:43 +0000 (UTC)
Author: svenp
Date: Sun Jun 8 11:34:43 2008
New Revision: 151
URL: http://svn.gnome.org/viewvc/soylent?rev=151&view=rev
Log:
test is now a simple test-suite with utility methods and the possibility to integrate new tests easily
Modified:
trunk/libsoylent/test/test.c
trunk/libsoylent/test/test.h
Modified: trunk/libsoylent/test/test.c
==============================================================================
--- trunk/libsoylent/test/test.c (original)
+++ trunk/libsoylent/test/test.c Sun Jun 8 11:34:43 2008
@@ -1,19 +1,66 @@
//
+#include "config.h"
#include "test.h"
-#include <libsoylent/soylent-person.h>
-#include <glib.h>
+#include <libsoylent/soylent.h>
+
#include <stdlib.h>
int main(int argc, char **argv) {
- g_print("welcome to libsoylent test v%s\n", SOYLENT_VERSION);
+ tests = NULL;
+
+ // TODO: why does this macro not work?
+ //g_print("Welcome to libsoylent Test v%s\n\n", LIBSOYLENT_VERSION);
+ g_print("Welcome to libsoylent Test v0.0.1!\n\n");
+
+ /* --- tests --- */
+ init();
+ playground();
+ /* insert more tests here... */
+ /* --- */
- g_print("starting test foo\n");
+ g_print("\n");
+ g_print("Test results:\n");
- g_print("hash: %d\n", soylent_person_foo("bar"));
+ int tests_count = g_list_length(tests);
+ int success_count = 0;
+ GList *tests_iter = tests;
+ for(; tests_iter != NULL; tests_iter = tests_iter->next) {
+ Test *test = tests_iter->data;
+
+ gchar result_char = ' ';
+ if (test->succeded) {
+ result_char = 'X';
+ success_count++;
+ }
+
+ g_print(" [%c] %s\n", result_char, test->name);
+ }
- g_print("i can do so much more\n");
+ g_print("\n");
+ g_print("%d / %d tests succeded\n", success_count, tests_count);
+
+ g_list_free(tests);
+
+ if (success_count != tests_count) {
+ return EXIT_FAILURE;
+ }
return EXIT_SUCCESS;
}
+
+Test *test_init(const gchar *name) {
+ Test *test = g_new(Test, 1);
+ test->name = (gchar *) name;
+ test->succeded = FALSE;
+ tests = g_list_append(tests, test);
+
+ g_print("Running test %s...\n", name);
+
+ return test;
+}
+
+void test_succeded(Test *test) {
+ test->succeded = TRUE;
+}
Modified: trunk/libsoylent/test/test.h
==============================================================================
--- trunk/libsoylent/test/test.h (original)
+++ trunk/libsoylent/test/test.h Sun Jun 8 11:34:43 2008
@@ -3,4 +3,21 @@
#ifndef TEST_H
#define TEST_H
+#include <glib.h>
+
+typedef struct _Test Test;
+
+struct _Test {
+ gchar *name;
+ gboolean succeded;
+};
+
+GList *tests;
+
+Test *test_init(const gchar *name);
+void test_succeded(Test *test);
+
+void init(void);
+void playground(void);
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]