summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuynh Tran <nthuynh75@gmail.com>2005-06-24 18:36:36 +0000
committerHuynh Tran <nthuynh75@gmail.com>2005-06-24 18:36:36 +0000
commit4b54d7283f8048819938eb34f125906704ec5eca (patch)
tree7c157eeedc56f04eefb4a16fdca29406d9159225
parent8a31e5c654af9a4b3261db3e290f08ce5629b071 (diff)
downloadmanaserv-4b54d7283f8048819938eb34f125906704ec5eca.tar.gz
manaserv-4b54d7283f8048819938eb34f125906704ec5eca.tar.bz2
manaserv-4b54d7283f8048819938eb34f125906704ec5eca.tar.xz
manaserv-4b54d7283f8048819938eb34f125906704ec5eca.zip
Fixed compilation warnings, the unit tests are now compiled if --enable-unit-tests is set.
-rw-r--r--configure.ac23
-rw-r--r--src/Makefile.am6
-rw-r--r--src/tests/Makefile.am46
-rw-r--r--src/tests/testaccount.cpp8
-rw-r--r--src/tests/teststorage.cpp5
5 files changed, 71 insertions, 17 deletions
diff --git a/configure.ac b/configure.ac
index 31e2d95a..614a0032 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,18 +127,19 @@ fi
AC_ARG_ENABLE(
[unit-tests],
AS_HELP_STRING([--enable-unit-tests], [compile the unit tests]),
- [],
+ [if test "$enableval" = "yes"; then
+ enable_unit_tests="$enableval"
+
+ # use cppunit-config to check the libcppunit.
+ # CPPUNIT_CFLAGS and CPPUNIT_LIBS are set by AC_CHECK_LIB_TMW.
+ AC_CHECK_LIB_TMW([cppunit], [1.10.2])
+ else
+ enable_unit_tests="no"
+ fi],
[enable_unit_tests="no"]
)
-# TODO
-# Configure the unit tests.
-#if test "$enable_unit_tests" = "yes" -a -d $srcdir/src/tests; then
-# AC_CONFIG_SUBDIRS([src/tests])
-#fi
-
-
AM_CONDITIONAL(BUILD_MYSQL, test "$with_storage_backend" = "mysql")
AM_CONDITIONAL(BUILD_POSTGRESQL, test "$with_storage_backend" = "postgresql")
AM_CONDITIONAL(BUILD_SQLITE, test "$with_storage_backend" = "sqlite")
@@ -146,9 +147,13 @@ AM_CONDITIONAL(BUILD_SQLITE, test "$with_storage_backend" = "sqlite")
AM_CONDITIONAL(BUILD_RUBY, test "$with_scripting_engine" = "ruby")
AM_CONDITIONAL(BUILD_SQUIRREL, test "$with_scripting_engine" = "squirrel")
+AM_CONDITIONAL(UNIT_TESTS_YES, test "$enable_unit_tests" = "yes")
+
AC_CONFIG_FILES([Makefile
- src/Makefile])
+ src/Makefile
+ src/tests/Makefile])
+
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index d567125b..e40dc501 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,4 +71,8 @@ tmwserv_SOURCES += script.h \
endif
tmwserv_CXXFLAGS = -Wall -fno-inline
-tmwserv_TARGET = tmwserv
+
+
+# do not remove the 'dot', it is a hint for Automake.
+# it causes a prefix ordering of directories.
+SUBDIRS = . tests
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
new file mode 100644
index 00000000..c8f53d06
--- /dev/null
+++ b/src/tests/Makefile.am
@@ -0,0 +1,46 @@
+# $Id$
+
+
+if UNIT_TESTS_YES
+
+bin_PROGRAMS = tmwserv_test
+
+tmwserv_test_SOURCES = testsmain.cpp \
+ testaccount.h \
+ testaccount.cpp \
+ testcipher.h \
+ testcipher.cpp \
+ testdataprovider.h \
+ testdataprovider.cpp \
+ testrecordset.h \
+ testrecordset.cpp \
+ teststorage.h \
+ teststorage.cpp
+
+tmwserv_test_CXXFLAGS = -Wall $(CPPUNIT_CXXFLAGS)
+
+tmwserv_test_LDFLAGS = $(CPPUNIT_LIBS)
+
+tmwserv_test_LDADD = ../tmwserv-account.o \
+ ../tmwserv-cipher.o \
+ ../tmwserv-dalstorage.o \
+ ../tmwserv-dataprovider.o \
+ ../tmwserv-dataproviderfactory.o \
+ ../tmwserv-logger.o \
+ ../tmwserv-object.o \
+ ../tmwserv-recordset.o \
+ ../tmwserv-storage.o
+
+if BUILD_MYSQL
+tmwserv_test_LDADD += ../tmwserv-mysqldataprovider.o
+endif
+
+if BUILD_POSTGRESQL
+tmwserv_test_LDADD += ../tmwserv-pqdataprovider.o
+endif
+
+if BUILD_SQLITE
+tmwserv_test_LDADD += ../tmwserv-sqlitedataprovider.o
+endif
+
+endif
diff --git a/src/tests/testaccount.cpp b/src/tests/testaccount.cpp
index a4061164..987ab81c 100644
--- a/src/tests/testaccount.cpp
+++ b/src/tests/testaccount.cpp
@@ -96,7 +96,7 @@ AccountTest::testCreate1(void)
Beings& characters = account.getCharacters();
- for (int i = 0; i < mCharacters.size(); ++i) {
+ for (size_t i = 0; i < mCharacters.size(); ++i) {
CPPUNIT_ASSERT_EQUAL(characters[i]->getName(),
mCharacters[i]->getName());
}
@@ -126,7 +126,7 @@ AccountTest::testCreate2(void)
Beings& characters = account.getCharacters();
- for (int i = 0; i < mCharacters.size(); ++i) {
+ for (size_t i = 0; i < mCharacters.size(); ++i) {
CPPUNIT_ASSERT_EQUAL(characters[i]->getName(),
mCharacters[i]->getName());
}
@@ -151,7 +151,7 @@ AccountTest::testAddCharacter1(void)
names.push_back("pippin");
names.push_back("bilbo");
- for (int i = 0; i < mCharacters.size(); ++i) {
+ for (size_t i = 0; i < mCharacters.size(); ++i) {
CPPUNIT_ASSERT_EQUAL(mCharacters[i]->getName(), names[i]);
}
@@ -174,7 +174,7 @@ AccountTest::testAddCharacter2(void)
names.push_back("merry");
names.push_back("pippin");
- for (int i = 0; i < mCharacters.size(); ++i) {
+ for (size_t i = 0; i < mCharacters.size(); ++i) {
CPPUNIT_ASSERT_EQUAL(mCharacters[i]->getName(), names[i]);
}
}
diff --git a/src/tests/teststorage.cpp b/src/tests/teststorage.cpp
index 9757fdf3..ac831513 100644
--- a/src/tests/teststorage.cpp
+++ b/src/tests/teststorage.cpp
@@ -301,9 +301,8 @@ StorageTest::insertAccount(std::auto_ptr<DataProvider>& db,
// the password will be identical to the name.
- sql << "insert into " << ACCOUNTS_TBL_NAME
- << "(username, password, email, level, banned) values "
- << "('" << name << "', '" << name << "', '"
+ sql << "insert into " << ACCOUNTS_TBL_NAME << " values "
+ << "(null, '" << name << "', '" << name << "', '"
<< name << "@domain', 1, 0);";
db->execSql(sql.str());