* set up (unit) test framework using gtester

This commit is contained in:
Dirk-Jan C. Binnema
2010-01-25 10:24:33 +02:00
parent 92202ac6eb
commit afcd800a2e
8 changed files with 172 additions and 7 deletions

View File

@ -14,6 +14,16 @@
## along with this program; if not, write to the Free Software Foundation,
## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
include $(top_srcdir)/gtest.mk
# enforce compiling this dir first before decending into tests/
SUBDIRS= .
if HAVE_GTEST
SUBDIRS += tests
endif
INCLUDES=$(XAPIAN_CXXFLAGS) $(GMIME_CFLAGS) $(GLIB_CFLAGS)
bin_PROGRAMS= \

45
src/tests/Makefile.am Normal file
View File

@ -0,0 +1,45 @@
## Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 3, or (at your option) any
## later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software Foundation,
## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
include $(top_srcdir)/gtest.mk
INCLUDES=$(XAPIAN_CXXFLAGS) \
$(GMIME_CFLAGS) \
$(GLIB_CFLAGS) \
-I ${top_srcdir} \
-DABS_SRCDIR=\"${abs_srcdir}\"
noinst_PROGRAMS= $(TEST_PROGS)
TEST_PROGS += test-util
test_util_SOURCES= test-util.c
test_util_LDADD= ${top_srcdir}/src/libmu.la
# note the question marks; make does not like files with ':'...
# 11 messages, the '.ignore' message should be ignored when indexing
# EXTRA_DIST= \
# TestMaildir/tmp/1220863087.12663.ignore \
# TestMaildir/new/1220863087.12663_9.mindcrime \
# TestMaildir/new/1220863087.12663_25.mindcrime \
# TestMaildir/new/1220863087.12663_21.mindcrime \
# TestMaildir/new/1220863087.12663_23.mindcrime \
# TestMaildir/cur/1220863087.12663_5.mindcrime?2,S \
# TestMaildir/cur/1220863087.12663_7.mindcrime?2,RS \
# TestMaildir/cur/1220863087.12663_15.mindcrime?2,PS \
# TestMaildir/cur/1220863087.12663_19.mindcrime?2,S \
# TestMaildir/cur/1220863042.12663_1.mindcrime?2,S \
# TestMaildir/cur/1220863060.12663_3.mindcrime?2,S

BIN
src/tests/test-util Executable file

Binary file not shown.

60
src/tests/test-util.c Normal file
View File

@ -0,0 +1,60 @@
/*
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 3, or (at your option) any
** later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation,
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /*HAVE_CONFIG_H*/
#include <glib.h>
#include <stdlib.h>
#include "src/mu-util.h"
static void
test_mu_util_dir_expand (void)
{
gchar *got, *expected;
got = mu_util_dir_expand ("~/Desktop");
expected = g_strdup_printf ("%s%cDesktop",
getenv("HOME"), G_DIR_SEPARATOR);
g_assert_cmpstr (got,==,expected);
g_free (got);
g_free (expected);
}
static void
shutup (void) {}
int
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/mu-util/mu-util-dir-expand-01",
test_mu_util_dir_expand);
g_log_set_handler (NULL,
G_LOG_LEVEL_DEBUG|G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_INFO,
(GLogFunc)shutup, NULL);
return g_test_run ();
}