From b5eaef81d4651d1e8003191ccf87a76442955a3a Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 15 May 2015 20:48:38 +0300 Subject: [PATCH] fixed tests under gcc --- tests/Makefile | 15 ++++++++++++--- tests/file_log.cpp | 6 +++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 7580ee7d..c1347d40 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,10 +1,19 @@ CXX ?= g++ CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -Wl,--no-as-needed -I../include +LDPFALGS = -pthread + +CPP_FILES := $(wildcard *.cpp) +OBJ_FILES := $(addprefix ./,$(notdir $(CPP_FILES:.cpp=.o))) + + +tests: $(OBJ_FILES) + $(CXX) $(CXXFLAGS) $(LDPFALGS) -o $@ $^ + +%.o: %.cpp + g++ $(CXXFLAGS) -c -o $@ $< -all: %.cpp - $(CXX) $^ -o tests $(CXXFLAGS) $(CXX_RELEASE_FLAGS) clean: - rm -f tests *.o logs/* + rm -f tests *.o logs/* rebuild: clean all diff --git a/tests/file_log.cpp b/tests/file_log.cpp index c57cd21f..5fc92664 100644 --- a/tests/file_log.cpp +++ b/tests/file_log.cpp @@ -4,7 +4,7 @@ static std::string file_contents(const std::string& filename) { std::ifstream ifs(filename); if (!ifs) - throw std::exception("Failed open file "); + throw std::runtime_error("Failed open file "); return std::string((std::istreambuf_iterator(ifs)), (std::istreambuf_iterator())); @@ -15,7 +15,7 @@ static std::size_t count_lines(const std::string& filename) { std::ifstream ifs(filename); if (!ifs) - throw std::exception("Failed open file "); + throw std::runtime_error("Failed open file "); std::string line; size_t counter = 0; @@ -28,7 +28,7 @@ std::ifstream::pos_type filesize(const std::string& filename) { std::ifstream ifs(filename, std::ifstream::ate | std::ifstream::binary); if (!ifs) - throw std::exception("Failed open file "); + throw std::runtime_error("Failed open file "); return ifs.tellg(); }