Added makefile support for unit tests.

This commit is contained in:
Gunnar Beutner 2012-05-28 11:53:51 +02:00
parent d130d6017f
commit fa158c5368
6 changed files with 58 additions and 12 deletions

View File

@ -12,7 +12,8 @@ SUBDIRS = \
jsonrpc \
icinga \
components \
icinga-app
icinga-app \
test
icinga2docdir = ${prefix}/share/doc/icinga2
icinga2doc_DATA = \

View File

@ -37,7 +37,7 @@ int delegate_fwd(int (TObject::*function)(TArgs), weak_ptr<TObject> wref, TArgs
template<class TObject, class TArgs>
function<int (TArgs)> bind_weak(int (TObject::*function)(TArgs), const weak_ptr<TObject>& wref)
{
return bind(&delegate_fwd<TObject, TArgs>, function, wref, _1);
return bind(&delegate_fwd<TObject, TArgs>, function, wref, placeholders::_1);
}
template<class TObject, class TArgs>

View File

@ -1,9 +1,10 @@
EXTRA_DIST=include
dist-hook:
mkdir -p boost && \
include:
rm -Rf boost && mkdir -p boost && \
bcp --boost=$(BOOST_PATH)/include tr1 smart_ptr bind function make_shared boost && \
rm -Rf include && \
mkdir include && \
mv boost/boost include/ && \
rm -Rf boost
rm -Rf include && mkdir include && \
mv boost/boost include/
clean:
rm -Rf include

View File

@ -37,11 +37,7 @@ AX_CXX_COMPILE_STDCXX_0X
AX_CXX_GCC_ABI_DEMANGLE
AX_PTHREAD
<<<<<<< Updated upstream
LT_INIT([dlopen disable-static])
=======
LT_INIT([dlopen shared disable-static win32-dll])
>>>>>>> Stashed changes
LT_CONFIG_LTDL_DIR([ltdl])
LTDL_INIT
@ -93,5 +89,6 @@ icinga/Makefile
icinga-app/Makefile
jsonrpc/Makefile
mmatch/Makefile
test/Makefile
Doxyfile
])

20
test/Makefile.am Normal file
View File

@ -0,0 +1,20 @@
## Process this file with automake to produce Makefile.in
TESTS = \
base-dictionary
check_PROGRAMS = \
base-dictionary
base_dictionary_SOURCES = \
base-dictionary.cpp
base_dictionary_CXXFLAGS = \
$(BOOST_CPPFLAGS) \
-I${top_srcdir}/base \
-I${top_srcdir}
base_dictionary_LDADD = \
$(BOOST_LDFLAGS) \
$(BOOST_UNIT_TEST_FRAMEWORK_LIB) \
${top_builddir}/base/libbase.la

27
test/base-dictionary.cpp Normal file
View File

@ -0,0 +1,27 @@
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE base_dictionary
#include <boost/test/unit_test.hpp>
#include <i2-base.h>
using namespace icinga;
BOOST_AUTO_TEST_CASE(construct)
{
Dictionary::Ptr dictionary = make_shared<Dictionary>();
BOOST_REQUIRE(dictionary);
}
BOOST_AUTO_TEST_CASE(setproperty)
{
Dictionary::Ptr dictionary = make_shared<Dictionary>();
dictionary->SetProperty("test1", 7);
dictionary->SetProperty("test2", "hello world");
long test1;
BOOST_REQUIRE(dictionary->GetProperty("test1", &test1));
BOOST_REQUIRE(test1 == 7);
string test2;
BOOST_REQUIRE(dictionary->GetProperty("test2", &test2));
BOOST_REQUIRE(test2 == "hello world");
}