Commit c38956bc authored by Gluttton's avatar Gluttton

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

Fix compile on linux gcc 4.8.1. Add include guard (pragma once) in boolinq.h, remove gmock include directives, add explicit include of <climits>, comment code which use std::vector of const int, clarify typenames inside utility templates.
parent 9e3d4743
#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"
...@@ -46,4 +45,4 @@ TEST(All, ThreeIntsSecond) ...@@ -46,4 +45,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"
...@@ -30,4 +29,4 @@ TEST(Any, ThreeInts) ...@@ -30,4 +29,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"
...@@ -124,4 +123,4 @@ TEST(BytesRange, IntsLF) ...@@ -124,4 +123,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
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include <set> #include <set>
#include "boolinq.h"
using namespace boolinq;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Compare Range with array // Compare Range with array
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -44,8 +48,8 @@ void CheckRangeEqSet(R dst, T (&ans)[N]) ...@@ -44,8 +48,8 @@ void CheckRangeEqSet(R dst, T (&ans)[N])
EXPECT_EQ(expected.size(), actual.size()); EXPECT_EQ(expected.size(), actual.size());
std::set<T>::iterator it1 = expected.begin(); typename std::set<T>::iterator it1 = expected.begin();
std::set<typename R::value_type>::iterator it2 = actual.begin(); typename std::set<typename R::value_type>::iterator it2 = actual.begin();
for(; it1 != expected.end() && it2 != actual.end(); it1++, it2++) for(; it1 != expected.end() && it2 != actual.end(); it1++, it2++)
{ {
EXPECT_EQ(*it2, *it1); EXPECT_EQ(*it2, *it1);
......
#include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "CommonTests.h" #include "CommonTests.h"
...@@ -56,4 +55,4 @@ TEST(ConcatRange, ArrayVectorArray) ...@@ -56,4 +55,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"
...@@ -44,4 +43,4 @@ TEST(Contains, FiveStrings) ...@@ -44,4 +43,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"
...@@ -101,4 +100,4 @@ TEST(DistinctRange, OneFieldFront) ...@@ -101,4 +100,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,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#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"
...@@ -38,4 +37,4 @@ TEST(ElementAt, FiveStrings) ...@@ -38,4 +37,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,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#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"
...@@ -130,4 +129,4 @@ TEST(GroupByRange, CountChildrenByAge) ...@@ -130,4 +129,4 @@ TEST(GroupByRange, CountChildrenByAge)
EXPECT_THROW(dst.nextObject(), EnumeratorEndException); EXPECT_THROW(dst.nextObject(), EnumeratorEndException);
} }
*/ */
\ No newline at end of file
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#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"
...@@ -92,4 +91,4 @@ TEST(IterRange, EmptyVector) ...@@ -92,4 +91,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,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#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"
...@@ -249,27 +248,27 @@ TEST(Linq, Creations) ...@@ -249,27 +248,27 @@ TEST(Linq, Creations)
int arr[] = {1,2,3,4,5}; int arr[] = {1,2,3,4,5};
int * ptr = (int*)arr; int * ptr = (int*)arr;
std::vector<const int> cvec; //std::vector<const int> cvec;
cvec.push_back(1); //cvec.push_back(1);
cvec.push_back(2); //cvec.push_back(2);
cvec.push_back(3); //cvec.push_back(3);
cvec.push_back(4); //cvec.push_back(4);
cvec.push_back(5); //cvec.push_back(5);
const int carr[] = {1,2,3,4,5}; const int carr[] = {1,2,3,4,5};
const int * cptr = (const int*)carr; const int * cptr = (const int*)carr;
auto dst_vec = from(vec); auto dst_vec = from(vec);
auto dst_cvec = from(cvec); //auto dst_cvec = from(cvec);
auto dst_arr = from(arr); auto dst_arr = from(arr);
auto dst_carr = from(carr); //auto dst_carr = from(carr);
auto dst_ptr = from<int>(ptr, ptr+5); auto dst_ptr = from<int>(ptr, ptr+5);
auto dst_cptr = from<const int>(cptr, cptr+5); //auto dst_cptr = from<const int>(cptr, cptr+5);
auto dst_ptr_length = from<int>(ptr, 5); auto dst_ptr_length = from<int>(ptr, 5);
auto dst_cptr_length = from<const int>(cptr, 5); //auto dst_cptr_length = from<const int>(cptr, 5);
auto dst_vec_iter = from<int>(vec.begin(), vec.end()); auto dst_vec_iter = from<int>(vec.begin(), vec.end());
auto dst_vec_citer = from<const int>(vec.cbegin(), vec.cend()); //auto dst_vec_citer = from<const int>(vec.cbegin(), vec.cend());
auto dst_cvec_iter = from<const int>(cvec.begin(), cvec.end()); //auto dst_cvec_iter = from<const int>(cvec.begin(), cvec.end());
auto dst_cvec_citer = from<const int>(cvec.cbegin(), cvec.cend()); //auto dst_cvec_citer = from<const int>(cvec.cbegin(), cvec.cend());
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
......
#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"
...@@ -32,4 +31,4 @@ TEST(Max, FiveStrings) ...@@ -32,4 +31,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"
...@@ -123,4 +122,4 @@ TEST(OrderByRange, RandomStringByLength) ...@@ -123,4 +122,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,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#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"
...@@ -31,4 +30,4 @@ TEST(ReverseRange, DoubleReverse) ...@@ -31,4 +30,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,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#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"
...@@ -42,4 +41,4 @@ TEST(UnbitsRange, OneByteLH) ...@@ -42,4 +41,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"
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
#pragma once
#include <set> #include <set>
#include <list> #include <list>
#include <deque> #include <deque>
...@@ -15,6 +17,7 @@ ...@@ -15,6 +17,7 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <functional> #include <functional>
#include <climits>
namespace boolinq namespace boolinq
{ {
......
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