]> granicus.if.org Git - icinga2/commitdiff
Added makefile support for unit tests.
authorGunnar Beutner <gunnar@beutner.name>
Mon, 28 May 2012 09:53:51 +0000 (11:53 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 28 May 2012 10:01:08 +0000 (12:01 +0200)
Makefile.am
base/delegate.h
compat/Makefile.am
configure.ac
test/Makefile.am [new file with mode: 0644]
test/base-dictionary.cpp [new file with mode: 0644]

index 3b14e55789b0651bdbd18d7c602f7889eaae2083..4b43ee5789c73a8e8907a75bb9ac135810876a0d 100644 (file)
@@ -12,7 +12,8 @@ SUBDIRS = \
        jsonrpc \
        icinga \
        components \
-       icinga-app
+       icinga-app \
+       test
 
 icinga2docdir = ${prefix}/share/doc/icinga2
 icinga2doc_DATA = \
index 81ee3f6b3470b1f23b124b9c5b971c19eea6a4e0..f1aa22e10d6fc3e8e8480ca5171655bb45a47f4b 100644 (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>
index 229d9e1a2cb22b36ff4a207ca5bad10a39622cf9..267c1c6c819bb0feb5c3a14f08f261fd5919d307 100644 (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
index 48263587e64f80dfb257d573d65d98276a949063..d0df6c4e188913d80ad8b04b2c52bb8ea50cd8f6 100644 (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
 ])
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644 (file)
index 0000000..7c4cce6
--- /dev/null
@@ -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
diff --git a/test/base-dictionary.cpp b/test/base-dictionary.cpp
new file mode 100644 (file)
index 0000000..62b8012
--- /dev/null
@@ -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");
+}