[evolution-data-server] tests: Port libebook/test-query.c to GTest
- From: Mathias Hasselmann <hasselmm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] tests: Port libebook/test-query.c to GTest
- Date: Wed, 16 Jan 2013 14:30:02 +0000 (UTC)
commit 303bec7d656e95a6ab6ac7de626d1cf1788aa565
Author: Mathias Hasselmann <mathias openismus com>
Date: Wed Dec 5 12:22:59 2012 +0100
tests: Port libebook/test-query.c to GTest
tests/libebook/test-query.c | 41 ++++++++++++++++++++---------------------
1 files changed, 20 insertions(+), 21 deletions(-)
---
diff --git a/tests/libebook/test-query.c b/tests/libebook/test-query.c
index 791383c..9561949 100644
--- a/tests/libebook/test-query.c
+++ b/tests/libebook/test-query.c
@@ -4,35 +4,34 @@
#define QUERY_STRING1
#define QUERY_STRING2
-static const gchar * queries[] = {
- "(exists \"full_name\")",
- "(contains \"full_name\" \"Miguel\")"
+static void
+test_sexp (gconstpointer data)
+{
+ EBookQuery *query = e_book_query_from_string (data);
+ char *sexp = e_book_query_to_string (query);
- /* XXX come on, add more here */
-};
+ g_assert_cmpstr (data, ==, sexp);
+
+ g_free (sexp);
+ e_book_query_unref (query);
+}
gint
main (gint argc,
gchar **argv)
{
- gint i;
- gboolean failure = FALSE;
+ g_type_init ();
- for (i = 0; i < G_N_ELEMENTS (queries); i++) {
- EBookQuery *query = e_book_query_from_string (queries[i]);
- gchar *str;
+ g_test_init (&argc, &argv, NULL);
- str = e_book_query_to_string (query);
+ g_test_add_data_func ("/libebook/test-query/sexp/exists",
+ "(exists \"full_name\")",
+ test_sexp);
+ g_test_add_data_func ("/libebook/test-query/sexp/contains",
+ "(contains \"full_name\" \"Miguel\")",
+ test_sexp);
- if (strcmp (str, queries[i])) {
- g_warning ("failed on query: %s", queries[i]);
-
- failure = TRUE;
- }
- }
-
- if (!failure)
- g_message ("all tests passed");
+ /* XXX come on, add more here */
- return 0;
+ return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]