Commit 3a75baf4 authored by Gluttton's avatar Gluttton

Fix compile tests on linux gcc 4.8.1. Add include guard (pragma once) in…

Fix compile tests on linux gcc 4.8.1. Add include guard (pragma once) in boolinq.h, add Makefile, add explicit include of <climits>, comment code which use std::vector of const int, clarify typenames inside utility templates.
parent c38956bc
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
...@@ -45,4 +46,4 @@ TEST(All, ThreeIntsSecond) ...@@ -45,4 +46,4 @@ TEST(All, ThreeIntsSecond)
EXPECT_FALSE(rng.all([](int a){return a>1;})); EXPECT_FALSE(rng.all([](int a){return a>1;}));
EXPECT_FALSE(rng.all([](int a){return a==1;})); EXPECT_FALSE(rng.all([](int a){return a==1;}));
EXPECT_FALSE(rng.all([](int a){return a<2;})); EXPECT_FALSE(rng.all([](int a){return a<2;}));
} }
\ No newline at end of file
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
...@@ -29,4 +30,4 @@ TEST(Any, ThreeInts) ...@@ -29,4 +30,4 @@ TEST(Any, ThreeInts)
EXPECT_FALSE(rng.any([](int a){return a==4;})); EXPECT_FALSE(rng.any([](int a){return a==4;}));
EXPECT_FALSE(rng.any([](int a){return a<1;})); EXPECT_FALSE(rng.any([](int a){return a<1;}));
EXPECT_FALSE(rng.any([](int a){return a>3;})); EXPECT_FALSE(rng.any([](int a){return a>3;}));
} }
\ No newline at end of file
#include <list> #include <list>
#include <vector> #include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
...@@ -123,4 +124,4 @@ TEST(BytesRange, IntsLF) ...@@ -123,4 +124,4 @@ TEST(BytesRange, IntsLF)
auto dst = rng.bytes(LastToFirst); auto dst = rng.bytes(LastToFirst);
CheckRangeEqArray(dst, ans); CheckRangeEqArray(dst, ans);
} }
\ No newline at end of file
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
...@@ -55,4 +56,4 @@ TEST(ConcatRange, ArrayVectorArray) ...@@ -55,4 +56,4 @@ TEST(ConcatRange, ArrayVectorArray)
auto dst = rng1.concat(rng2).concat(rng3); auto dst = rng1.concat(rng2).concat(rng3);
CheckRangeEqArray(dst, ans); CheckRangeEqArray(dst, ans);
} }
\ No newline at end of file
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
...@@ -43,4 +44,4 @@ TEST(Contains, FiveStrings) ...@@ -43,4 +44,4 @@ TEST(Contains, FiveStrings)
EXPECT_FALSE(rng.contains("dino")); EXPECT_FALSE(rng.contains("dino"));
EXPECT_FALSE(rng.contains("lord")); EXPECT_FALSE(rng.contains("lord"));
} }
\ No newline at end of file
#include <list> #include <list>
#include <vector> #include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
...@@ -100,4 +101,4 @@ TEST(DistinctRange, OneFieldFront) ...@@ -100,4 +101,4 @@ TEST(DistinctRange, OneFieldFront)
auto dst = rng.distinct([](const Man & man){return man.age;}); auto dst = rng.distinct([](const Man & man){return man.age;});
CheckRangeEqSet(dst, ans); CheckRangeEqSet(dst, ans);
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
...@@ -37,4 +38,4 @@ TEST(ElementAt, FiveStrings) ...@@ -37,4 +38,4 @@ TEST(ElementAt, FiveStrings)
EXPECT_EQ("nokia", rng.elementAt(2)); EXPECT_EQ("nokia", rng.elementAt(2));
EXPECT_EQ("oracle", rng.elementAt(3)); EXPECT_EQ("oracle", rng.elementAt(3));
EXPECT_EQ("ponny", rng.elementAt(4)); EXPECT_EQ("ponny", rng.elementAt(4));
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
...@@ -129,4 +130,4 @@ TEST(GroupByRange, CountChildrenByAge) ...@@ -129,4 +130,4 @@ TEST(GroupByRange, CountChildrenByAge)
EXPECT_THROW(dst.nextObject(), EnumeratorEndException); EXPECT_THROW(dst.nextObject(), EnumeratorEndException);
} }
*/ */
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
...@@ -91,4 +92,4 @@ TEST(IterRange, EmptyVector) ...@@ -91,4 +92,4 @@ TEST(IterRange, EmptyVector)
auto rng = from(src); auto rng = from(src);
EXPECT_THROW(rng.nextObject(), EnumeratorEndException); EXPECT_THROW(rng.nextObject(), EnumeratorEndException);
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
OPTIMIZATION ?= O0
ifdef COV
COVERAGE = -fprofile-arcs -ftest-coverage
endif
ifdef PROF
PROFILE = -pg
endif
CXX = g++
INCLUDES = -I.
CXXFLAGS = -c \
-MD \
-std=c++11 -march=native -mtune=native \
-Wall -Wextra \
-$(OPTIMIZATION) \
$(COVERAGE) \
$(PROFILE)
LDPATH =
LDADD = -lgtest -lgtest_main -lpthread \
$(COVERAGE) \
$(PROFILE)
SRC = AllTest.cpp \
AnyTest.cpp \
AvgTest.cpp \
BitsRangeTest.cpp \
BytesRangeTest.cpp \
ConcatRangeTest.cpp \
ContainsTest.cpp \
CountTest.cpp \
DistinctRangeTest.cpp \
DotCallTest.cpp \
ElementAtTest.cpp \
ForeachTest.cpp \
GroupByRangeTest.cpp \
IterRangeTest.cpp \
LinqTest.cpp \
MaxTest.cpp \
MinTest.cpp \
OrderByRangeTest.cpp \
ReverseRangeTest.cpp \
SelectRangeTest.cpp \
SkipRangeTest.cpp \
SkipWhileRangeTest.cpp \
SpeedTest.cpp \
SumTest.cpp \
TakeRangeTest.cpp \
TakeWhileRangeTest.cpp \
ToDequeTest.cpp \
ToListTest.cpp \
ToSetTest.cpp \
ToVectorTest.cpp \
UnbitsRangeTest.cpp \
UnbytesRangeTest.cpp \
WhereRangeTest.cpp
OBJ = $(SRC:.cpp=.o)
TEST = boolinqtest
COV_DATA = $(shell find . -type f -name '*.d' -o -name '*.gcov' -o -name '*.gcda' -o -name '*.gcno' -o -name 'coverage' -o -name 'coverage.info')
PRO_DATA = $(shell find . -type f -name 'gmon.out')
TMP_DATA = $(shell find . -type f -name '*~')
all: $(TEST)
$(TEST): $(OBJ)
$(CXX) $(OBJ) $(LDPATH) $(LDADD) -o $@
.cpp.o:
$(CXX) $(CXXFLAGS) $(INCLUDES) $< -o $@
clean:
rm -rf $(OBJ) $(TEST) $(TMP_DATA) $(COV_DATA) $(PRO_DATA)
coverage:
lcov -q -c -f -b . -d . -o coverage.info &&\
lcov -q -r coverage.info /usr/\* -b . -d . -o coverage.info &&\
genhtml coverage.info --demangle-cpp --legend -f -q -o coverage
profile:
gprof $(TEST) gmon.out -b -Q
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
...@@ -31,4 +32,4 @@ TEST(Max, FiveStrings) ...@@ -31,4 +32,4 @@ TEST(Max, FiveStrings)
EXPECT_EQ("zip", rng.max()); EXPECT_EQ("zip", rng.max());
EXPECT_EQ("apple", rng.max([](std::string s){return s.size();})); EXPECT_EQ("apple", rng.max([](std::string s){return s.size();}));
} }
\ No newline at end of file
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
...@@ -122,4 +123,4 @@ TEST(OrderByRange, RandomStringByLength) ...@@ -122,4 +123,4 @@ TEST(OrderByRange, RandomStringByLength)
auto dst = rng.orderBy([](std::string a){return a.size();}); auto dst = rng.orderBy([](std::string a){return a.size();});
CheckRangeEqArray(dst, ans, [](const std::string & s){return s.size();}); CheckRangeEqArray(dst, ans, [](const std::string & s){return s.size();});
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
...@@ -30,4 +31,4 @@ TEST(ReverseRange, DoubleReverse) ...@@ -30,4 +31,4 @@ TEST(ReverseRange, DoubleReverse)
auto dst = rng.reverse().reverse(); auto dst = rng.reverse().reverse();
CheckRangeEqArray(dst, ans); CheckRangeEqArray(dst, ans);
} }
\ No newline at end of file
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <iostream> #include <iostream>
......
#include <list> #include <list>
#include <vector> #include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <deque> #include <deque>
#include <vector> #include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
#include <deque> #include <deque>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
#include <list> #include <list>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
#include <vector> #include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
#include <vector> #include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "boolinq.h" #include "boolinq.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
...@@ -41,4 +42,4 @@ TEST(UnbitsRange, OneByteLH) ...@@ -41,4 +42,4 @@ TEST(UnbitsRange, OneByteLH)
auto dst = rng.unbits(LowToHigh); auto dst = rng.unbits(LowToHigh);
CheckRangeEqArray(dst, ans); CheckRangeEqArray(dst, ans);
} }
\ No newline at end of file
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
#include <vector> #include <vector>
#include <string> #include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment