Browse Source

Setup unit test environment.

pull/228/head
EinMByte 10 years ago
parent
commit
5d78e2f5e4
  1. 1
      .gitignore
  2. 12
      Makefile
  3. 1
      Makefile.bsd
  4. 3
      Makefile.linux
  5. 1
      Makefile.osx
  6. 3
      filelist.mk
  7. 12
      tests/Identity.cpp
  8. 19
      tests/Utility.cpp

1
.gitignore vendored

@ -6,6 +6,7 @@ i2p @@ -6,6 +6,7 @@ i2p
libi2pd.so
netDb
tunnels.cfg
tests/tests
# Autotools
autom4te.cache

12
Makefile

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
UNAME := $(shell uname -s)
SHLIB := libi2pd.so
I2PD := i2p
TESTS := tests/tests
GREP := fgrep
DEPS := obj/make.dep
@ -22,10 +23,11 @@ else # win32 @@ -22,10 +23,11 @@ else # win32
DAEMON_SRC += DaemonWin32.cpp
endif
all: mk_build_dir $(SHLIB) $(I2PD)
all: mk_build_dir $(SHLIB) $(I2PD) $(TESTS)
mk_build_dir:
mkdir -p obj
mkdir -p obj/tests
api: $(SHLIB)
@ -38,11 +40,13 @@ api: $(SHLIB) @@ -38,11 +40,13 @@ api: $(SHLIB)
deps:
@mkdir -p obj
@mkdir -p obj/tests
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) -MM *.cpp > $(DEPS)
@sed -i -e '/\.o:/ s/^/obj\//' $(DEPS)
obj/%.o : %.cpp
@mkdir -p obj
@mkdir -p obj/tests
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $<
# '-' is 'ignore if missing' on first run
@ -56,9 +60,13 @@ ifneq ($(USE_STATIC),yes) @@ -56,9 +60,13 @@ ifneq ($(USE_STATIC),yes)
$(CXX) $(LDFLAGS) $(LDLIBS) -shared -o $@ $^
endif
$(TESTS): $(patsubst %.cpp,obj/%.o,$(TESTS_SRC))
$(CXX) -o $@ $^ $(LDLIBS) $(LDTESTLIBS) $(LDFLAGS)
clean:
rm -rf obj
$(RM) $(I2PD) $(SHLIB)
$(RM) $(I2PD) $(SHLIB) $(TESTS)
LATEST_TAG=$(shell git describe --tags --abbrev=0 master)
dist:

1
Makefile.bsd

@ -10,3 +10,4 @@ NEEDED_CXXFLAGS = -std=c++11 @@ -10,3 +10,4 @@ NEEDED_CXXFLAGS = -std=c++11
INCFLAGS = -I/usr/include/ -I/usr/local/include/
LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib
LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
LDTESTLIBS = -lboost_unit_test_framework

3
Makefile.linux

@ -40,6 +40,9 @@ else @@ -40,6 +40,9 @@ else
LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
endif
# Always link with test framework dynamically
LDTESTLIBS = -lboost_unit_test_framework
# UPNP Support (miniupnpc 1.5 or 1.6)
ifeq ($(USE_UPNP),1)
LDFLAGS += -ldl

1
Makefile.osx vendored

@ -4,6 +4,7 @@ CXXFLAGS = -g -Wall -std=c++11 -DCRYPTOPP_DISABLE_ASM -DMAC_OSX @@ -4,6 +4,7 @@ CXXFLAGS = -g -Wall -std=c++11 -DCRYPTOPP_DISABLE_ASM -DMAC_OSX
INCFLAGS = -I/usr/local/include
LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib
LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
LDTESTLIBS = -lboost_unit_test_framework
ifeq ($(USE_UPNP),1)
LDFLAGS += -ldl

3
filelist.mk

@ -23,3 +23,6 @@ DAEMON_SRC = $(COMMON_SRC) \ @@ -23,3 +23,6 @@ DAEMON_SRC = $(COMMON_SRC) \
LIB_SRC := $(COMMON_SRC) \
api.cpp
TESTS_SRC := $(COMMON_SRC) \
tests/Utility.cpp tests/Identity.cpp

12
tests/Identity.cpp

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "../Identity.h"
BOOST_AUTO_TEST_SUITE(IdentityTests)
BOOST_AUTO_TEST_SUITE_END()

19
tests/Utility.cpp

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
#include <boost/test/unit_test.hpp>
#include "../util.h"
BOOST_AUTO_TEST_SUITE(UtilityTests)
using namespace i2p::util::http;
BOOST_AUTO_TEST_CASE(DecodeEmptyUrl)
{
BOOST_CHECK_EQUAL(urlDecode(""), "");
}
BOOST_AUTO_TEST_CASE(DecodeUrl)
{
BOOST_CHECK_EQUAL(urlDecode("%20"), " ");
}
BOOST_AUTO_TEST_SUITE_END()
Loading…
Cancel
Save