-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Toon Schoenmakers
committed
May 30, 2014
1 parent
41d3d4b
commit 74fd52a
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
gtest-1.7.0.zip | ||
gtest-1.7.0/ | ||
*.o | ||
*.a | ||
test.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
override CXXFLAGS += -Wall -g -O0 -pipe -std=c++11 | ||
INC += -I../ -I. -Igtest-1.7.0/include | ||
CC := cc | ||
CXX := c++ | ||
|
||
VALGRIND := valgrind | ||
|
||
BINARY := test.out | ||
DEPS := $(patsubst %.cpp, %.o, $(shell find . -name \*.cpp -type f)) | ||
|
||
all: $(BINARY) | ||
|
||
%.o: %.cpp libgtest.a | ||
$(CXX) $(CXXFLAGS) $(DEFINES) $(INC) -c $< -o $@ | ||
|
||
$(BINARY): $(DEPS) $(MODS) main.cpp | ||
$(CXX) $(CXXFLAGS) $(DEFINES) $(INC) -o $(BINARY) $(DEPS) libgtest.a -pthread -lev -lreactcpp ../src/libreactcpp-curl.so | ||
|
||
libgtest.a: | ||
wget -q http://googletest.googlecode.com/files/gtest-1.7.0.zip | ||
unzip -qq gtest-1.7.0.zip | ||
$(CXX) $(CXXFLAGS) -I gtest-1.7.0/include -I gtest-1.7.0 -c gtest-1.7.0/src/gtest-all.cc | ||
ar -rv libgtest.a gtest-all.o | ||
|
||
.PHONY: test | ||
|
||
test: $(BINARY) | ||
./$(BINARY) | ||
|
||
.PHONY: valgrind | ||
|
||
valgrind: $(BINARY) | ||
$(VALGRIND) $(VALGRIND_OPTS) ./$(BINARY) | ||
|
||
.PHONY: clean | ||
|
||
clean: | ||
rm -rf $(BINARY) $(DEPS) $(MODS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Http.cpp | ||
* | ||
* Http related tests | ||
* | ||
* @copyright 2014 Copernica BV | ||
*/ | ||
|
||
#include <../curl.h> | ||
#include <gtest/gtest.h> | ||
|
||
TEST(Http, Http) | ||
{ | ||
React::MainLoop loop; | ||
// Timeout after 5 seconds | ||
loop.onTimeout(5.0, [&loop]() { | ||
loop.stop(); | ||
FAIL() << "Timeout"; | ||
}); | ||
|
||
React::Curl::CurlMulti multi(&loop); | ||
|
||
React::Curl::Request request(&multi, "http://httpbin.org/headers"); | ||
request.execute().onComplete([&loop]() { | ||
loop.stop(); | ||
}); | ||
|
||
loop.run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Main.cpp | ||
* | ||
* Start point of the unit tests | ||
* | ||
* @copyright 2014 Copernica BV | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
int main(int argc, char** argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
::testing::FLAGS_gtest_shuffle = true; | ||
return RUN_ALL_TESTS(); | ||
}; |