Commit 89aabe3b authored by Anton Bukov's avatar Anton Bukov

Fix some issues

parent ecab6f46
...@@ -18,7 +18,7 @@ int src[] = {1,2,3,4,5,6,7,8}; ...@@ -18,7 +18,7 @@ int src[] = {1,2,3,4,5,6,7,8};
auto dst = from(src).where( [](int a){return a%2 == 1;}) // 1,3,5,7 auto dst = from(src).where( [](int a){return a%2 == 1;}) // 1,3,5,7
.select([](int a){return a*2;}) // 2,6,10,14 .select([](int a){return a*2;}) // 2,6,10,14
.where( [](int a){return a>2 && a<12;}) // 6,10 .where( [](int a){return a>2 && a<12;}) // 6,10
.toVector(); .toStdVector();
// dst type: std::vector<int> // dst type: std::vector<int>
// dst items: 6,10 // dst items: 6,10
...@@ -45,7 +45,7 @@ Man src[] = ...@@ -45,7 +45,7 @@ Man src[] =
auto dst = from(src).where( [](const Man & man){return man.age < 18;}) auto dst = from(src).where( [](const Man & man){return man.age < 18;})
.orderBy([](const Man & man){return man.age;}) .orderBy([](const Man & man){return man.age;})
.select( [](const Man & man){return man.name;}) .select( [](const Man & man){return man.name;})
.toVector(); .toStdVector();
// dst type: std::vector<std::string> // dst type: std::vector<std::string>
// dst items: "Kevin", "Layer", "Agata" // dst items: "Kevin", "Layer", "Agata"
...@@ -90,14 +90,20 @@ int DenisUniqueContactCount = ...@@ -90,14 +90,20 @@ int DenisUniqueContactCount =
- cast&lt;T&gt;() - cast&lt;T&gt;()
- take(int) - take(int)
- takeWhile(int)
- takeWhile_i(int)
- skip(int) - skip(int)
- skipWhile(int)
- skipWhile_i(int)
- concat(range) - concat(range)
- where(lambda) - where(lambda)
- where_i(lambda)
- select(lambda) - select(lambda)
- select_i(lambda)
- selectMany(lambda)
- reverse() - reverse()
- orderBy() - orderBy()
- orderBy(lambda) - orderBy(lambda)
- groupBy(lambda)
- distinct() - distinct()
- distinct(lambda) - distinct(lambda)
- for_each(lambda) - for_each(lambda)
...@@ -114,14 +120,16 @@ int DenisUniqueContactCount = ...@@ -114,14 +120,16 @@ int DenisUniqueContactCount =
- max() - max()
- max(lambda) - max(lambda)
- count() - count()
- count(lambda)
- contains(value) - contains(value)
- elementAt(int) - elementAt(int)
- toSet() - toStdSet()
- toList() - toStdList()
- toDeque() - toStdDeque()
- toVector() - toStdVector()
- toContainer&lt;T&gt;()
#### Coming soon:
- groupBy(lambda)
#### Custom: #### Custom:
...@@ -138,10 +146,6 @@ int DenisUniqueContactCount = ...@@ -138,10 +146,6 @@ int DenisUniqueContactCount =
- unbits&lt;T,BitOrder&gt;() - unbits&lt;T,BitOrder&gt;()
- unbits&lt;T,BitOrder,ByteOrder&gt;() - unbits&lt;T,BitOrder,ByteOrder&gt;()
#### Coming soon:
- selectMany(lambda)
#### May be will be: #### May be will be:
- gz() - gz()
......
This diff is collapsed.
This diff is collapsed.
...@@ -14,18 +14,18 @@ template<typename R, typename T, unsigned N, typename F> ...@@ -14,18 +14,18 @@ template<typename R, typename T, unsigned N, typename F>
void CheckRangeEqArray(R dst, T (&ans)[N], F f) void CheckRangeEqArray(R dst, T (&ans)[N], F f)
{ {
for (unsigned i = 0; i < N; i++) for (unsigned i = 0; i < N; i++)
EXPECT_EQ(f(ans[i]), f(dst.nextObject())); EXPECT_EQ(f(ans[i]), f(dst.next()));
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
template<typename R, typename T, unsigned N> template<typename R, typename T, unsigned N>
void CheckRangeEqArray(R dst, T (&ans)[N]) void CheckRangeEqArray(R dst, T (&ans)[N])
{ {
for (unsigned i = 0; i < N; i++) for (unsigned i = 0; i < N; i++)
EXPECT_EQ(ans[i], dst.nextObject()); EXPECT_EQ(ans[i], dst.next());
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
template<typename T, unsigned N> template<typename T, unsigned N>
...@@ -44,7 +44,7 @@ template<typename R, typename T, unsigned N> ...@@ -44,7 +44,7 @@ template<typename R, typename T, unsigned N>
void CheckRangeEqSet(R dst, T (&ans)[N]) void CheckRangeEqSet(R dst, T (&ans)[N])
{ {
std::set<T> expected = ArrayToSet(ans); std::set<T> expected = ArrayToSet(ans);
std::set<typename R::value_type> actual = dst.toSet(); std::set<typename R::value_type> actual = dst.toStdSet();
EXPECT_EQ(expected.size(), actual.size()); EXPECT_EQ(expected.size(), actual.size());
......
...@@ -41,7 +41,7 @@ TEST(GroupByRange, IntsFront) ...@@ -41,7 +41,7 @@ TEST(GroupByRange, IntsFront)
CheckRangeEqArray(dst.back(), ans_0); CheckRangeEqArray(dst.back(), ans_0);
CheckRangeEqArray(dst.popFront(), ans_0); CheckRangeEqArray(dst.popFront(), ans_0);
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(GroupByRange, IntsBack) TEST(GroupByRange, IntsBack)
...@@ -73,7 +73,7 @@ TEST(GroupByRange, IntsBack) ...@@ -73,7 +73,7 @@ TEST(GroupByRange, IntsBack)
CheckRangeEqArray(dst.back(), ans_1); CheckRangeEqArray(dst.back(), ans_1);
CheckRangeEqArray(dst.popBack(), ans_1); CheckRangeEqArray(dst.popBack(), ans_1);
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -126,7 +126,7 @@ TEST(GroupByRange, CountChildrenByAge) ...@@ -126,7 +126,7 @@ TEST(GroupByRange, CountChildrenByAge)
CheckRangeEqArray(dst.back(), ans_true); CheckRangeEqArray(dst.back(), ans_true);
CheckRangeEqArray(dst.popFront(), ans_true); CheckRangeEqArray(dst.popFront(), ans_true);
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
*/ */
...@@ -27,8 +27,8 @@ TEST(IterRange, ListInt) ...@@ -27,8 +27,8 @@ TEST(IterRange, ListInt)
int ans[] = {1,2,3,4,5}; int ans[] = {1,2,3,4,5};
CheckRangeEqArray(from(lst), ans); CheckRangeEqArray(from(lst), ans);
CheckRangeEqArray(from<int>(lst.begin(), lst.end()), ans); CheckRangeEqArray(from(lst.begin(), lst.end()), ans);
CheckRangeEqArray(from<int>(lst.cbegin(), lst.cend()), ans); CheckRangeEqArray(from(lst.cbegin(), lst.cend()), ans);
} }
TEST(IterRange, DequeInt) TEST(IterRange, DequeInt)
...@@ -43,8 +43,8 @@ TEST(IterRange, DequeInt) ...@@ -43,8 +43,8 @@ TEST(IterRange, DequeInt)
int ans[] = {1,2,3,4,5}; int ans[] = {1,2,3,4,5};
CheckRangeEqArray(from(dck), ans); CheckRangeEqArray(from(dck), ans);
CheckRangeEqArray(from<int>(dck.begin(), dck.end()), ans); CheckRangeEqArray(from(dck.begin(), dck.end()), ans);
CheckRangeEqArray(from<int>(dck.cbegin(), dck.cend()), ans); CheckRangeEqArray(from(dck.cbegin(), dck.cend()), ans);
} }
TEST(IterRange, VectorInt) TEST(IterRange, VectorInt)
...@@ -59,8 +59,8 @@ TEST(IterRange, VectorInt) ...@@ -59,8 +59,8 @@ TEST(IterRange, VectorInt)
int ans[] = {1,2,3,4,5}; int ans[] = {1,2,3,4,5};
CheckRangeEqArray(from(vec), ans); CheckRangeEqArray(from(vec), ans);
CheckRangeEqArray(from<int>(vec.begin(), vec.end()), ans); CheckRangeEqArray(from(vec.begin(), vec.end()), ans);
CheckRangeEqArray(from<int>(vec.cbegin(), vec.cend()), ans); CheckRangeEqArray(from(vec.cbegin(), vec.cend()), ans);
} }
TEST(IterRange, SetInt) TEST(IterRange, SetInt)
...@@ -69,22 +69,22 @@ TEST(IterRange, SetInt) ...@@ -69,22 +69,22 @@ TEST(IterRange, SetInt)
int ans[] = {1,2,3,4,5}; int ans[] = {1,2,3,4,5};
CheckRangeEqSet(from(set), ans); CheckRangeEqSet(from(set), ans);
CheckRangeEqSet(from<int>(set.begin(), set.end()), ans); CheckRangeEqSet(from(set.begin(), set.end()), ans);
CheckRangeEqSet(from<int>(set.cbegin(), set.cend()), ans); CheckRangeEqSet(from(set.cbegin(), set.cend()), ans);
} }
TEST(IterRange, MapInt) //TEST(IterRange, MapInt)
{ //{
std::map<int, int> map = {{5,1},{4,2},{3,3},{2,4},{1,5}}; // std::map<int, int> map = {{5,1},{4,2},{3,3},{2,4},{1,5}};
std::pair<int, int> ans[] = {{5,1},{4,2},{3,3},{2,4},{1,5}}; // std::pair<int, int> ans[] = {{5,1},{4,2},{3,3},{2,4},{1,5}};
//
CheckRangeEqArray(from(map) // CheckRangeEqArray(from(map)
.orderBy([](std::pair<int,int> p){ return p.second; }), ans); // .orderBy([](std::pair<int,int> p){ return p.second; }), ans);
CheckRangeEqArray(from<std::pair<int,int> >(map.begin(), map.end()) // CheckRangeEqArray(from(map.begin(), map.end())
.orderBy([](std::pair<int,int> p){ return p.second; }), ans); // .orderBy([](std::pair<int,int> p){ return p.second; }), ans);
CheckRangeEqArray(from<std::pair<int,int> >(map.cbegin(), map.cend()) // CheckRangeEqArray(from(map.cbegin(), map.cend())
.orderBy([](std::pair<int,int> p){ return p.second; }), ans); // .orderBy([](std::pair<int,int> p){ return p.second; }), ans);
} //}
TEST(IterRange, StdArrayInt) TEST(IterRange, StdArrayInt)
{ {
...@@ -92,8 +92,8 @@ TEST(IterRange, StdArrayInt) ...@@ -92,8 +92,8 @@ TEST(IterRange, StdArrayInt)
int ans[] = {1,2,3,4,5}; int ans[] = {1,2,3,4,5};
CheckRangeEqArray(from(arr), ans); CheckRangeEqArray(from(arr), ans);
CheckRangeEqArray(from<int>(arr.begin(), arr.end()), ans); CheckRangeEqArray(from(arr.begin(), arr.end()), ans);
CheckRangeEqArray(from<int>(arr.cbegin(), arr.cend()), ans); CheckRangeEqArray(from(arr.cbegin(), arr.cend()), ans);
} }
TEST(IterRange, ArrayInt) TEST(IterRange, ArrayInt)
...@@ -104,8 +104,8 @@ TEST(IterRange, ArrayInt) ...@@ -104,8 +104,8 @@ TEST(IterRange, ArrayInt)
int ans[] = {1,2,3,4,5}; int ans[] = {1,2,3,4,5};
CheckRangeEqArray(from(arr), ans); CheckRangeEqArray(from(arr), ans);
CheckRangeEqArray(from<int>(ptr, 5), ans); CheckRangeEqArray(from(ptr, 5), ans);
CheckRangeEqArray(from<int>(ptr, ptr+5), ans); CheckRangeEqArray(from(ptr, ptr + 5), ans);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -126,5 +126,5 @@ TEST(IterRange, EmptyVector) ...@@ -126,5 +126,5 @@ TEST(IterRange, EmptyVector)
auto rng = from(src); auto rng = from(src);
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
...@@ -25,10 +25,10 @@ TEST(Linq, WhereOdd) ...@@ -25,10 +25,10 @@ TEST(Linq, WhereOdd)
for (int i = 1; i <= 5; i+=2) for (int i = 1; i <= 5; i+=2)
{ {
EXPECT_EQ(i, rng.nextObject()); EXPECT_EQ(i, rng.next());
} }
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
TEST(Linq, WhereOdd_WhereLess) TEST(Linq, WhereOdd_WhereLess)
...@@ -48,10 +48,10 @@ TEST(Linq, WhereOdd_WhereLess) ...@@ -48,10 +48,10 @@ TEST(Linq, WhereOdd_WhereLess)
for (int i = 1; i <= 3; i+=2) for (int i = 1; i <= 3; i+=2)
{ {
EXPECT_EQ(i, rng.nextObject()); EXPECT_EQ(i, rng.next());
} }
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
TEST(Linq, WhereLess_WhereOdd) TEST(Linq, WhereLess_WhereOdd)
...@@ -68,7 +68,7 @@ TEST(Linq, WhereLess_WhereOdd) ...@@ -68,7 +68,7 @@ TEST(Linq, WhereLess_WhereOdd)
auto rng = from(src).where([](int a){return a < 4;}) auto rng = from(src).where([](int a){return a < 4;})
.where([](int a){return a%2 == 1;}) .where([](int a){return a%2 == 1;})
.toVector(); .toStdVector();
std::vector<int> ans; std::vector<int> ans;
ans.push_back(1); ans.push_back(1);
...@@ -92,7 +92,7 @@ TEST(Linq, WhereLess_WhereOdd_OrderByDesc) ...@@ -92,7 +92,7 @@ TEST(Linq, WhereLess_WhereOdd_OrderByDesc)
auto rng = from(src).where([](int a){return a < 6;}) auto rng = from(src).where([](int a){return a < 6;})
.where([](int a){return a%2 == 1;}) .where([](int a){return a%2 == 1;})
.orderBy([](int a){return -a;}) .orderBy([](int a){return -a;})
.toVector(); .toStdVector();
std::vector<int> ans; std::vector<int> ans;
ans.push_back(5); ans.push_back(5);
...@@ -115,7 +115,7 @@ TEST(Linq, WhereOdd_ToVector) ...@@ -115,7 +115,7 @@ TEST(Linq, WhereOdd_ToVector)
src.push_back(8); src.push_back(8);
auto dst = from(src).where([](int a){return a%2 == 1;}) auto dst = from(src).where([](int a){return a%2 == 1;})
.toVector(); .toStdVector();
std::vector<int> ans; std::vector<int> ans;
ans.push_back(1); ans.push_back(1);
...@@ -141,7 +141,7 @@ TEST(Linq, WhereOdd_WhereLess_SelectMul2_ToVector) ...@@ -141,7 +141,7 @@ TEST(Linq, WhereOdd_WhereLess_SelectMul2_ToVector)
auto dst = from(src).where([](int a){return a%2 == 1;}) auto dst = from(src).where([](int a){return a%2 == 1;})
.where([](int a){return a < 6;}) .where([](int a){return a < 6;})
.select([](int a){return a*2;}) .select([](int a){return a*2;})
.toVector(); .toStdVector();
std::vector<int> ans; std::vector<int> ans;
ans.push_back(2); ans.push_back(2);
...@@ -167,7 +167,7 @@ TEST(Linq, WhereOdd_WhereLess_SelectMul2_Reverse_ToVector) ...@@ -167,7 +167,7 @@ TEST(Linq, WhereOdd_WhereLess_SelectMul2_Reverse_ToVector)
.where([](int a){return a < 6;}) .where([](int a){return a < 6;})
.select([](int a){return a*2;}) .select([](int a){return a*2;})
.reverse() .reverse()
.toVector(); .toStdVector();
std::vector<int> ans; std::vector<int> ans;
ans.push_back(10); ans.push_back(10);
...@@ -193,7 +193,7 @@ TEST(Linq, WhereOdd_Reverse_Reverse) ...@@ -193,7 +193,7 @@ TEST(Linq, WhereOdd_Reverse_Reverse)
.reverse() .reverse()
.where([](int a){return a < 4;}) .where([](int a){return a < 4;})
.reverse() .reverse()
.toVector(); .toStdVector();
std::vector<int> ans; std::vector<int> ans;
ans.push_back(1); ans.push_back(1);
...@@ -208,14 +208,14 @@ TEST(Linq, Pointer_Front) ...@@ -208,14 +208,14 @@ TEST(Linq, Pointer_Front)
{ {
int src[] = {1,2,3,4,5}; int src[] = {1,2,3,4,5};
auto dst = from<int>(static_cast<int *>(src), static_cast<int *>(src) + 5); auto dst = from(static_cast<int *>(src), static_cast<int *>(src) + 5);
for(int i = 1; i <= 5; i++) for(int i = 1; i <= 5; i++)
{ {
EXPECT_EQ(i, dst.nextObject()); EXPECT_EQ(i, dst.next());
} }
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
...@@ -229,10 +229,10 @@ TEST(Linq, Array_Front) ...@@ -229,10 +229,10 @@ TEST(Linq, Array_Front)
for(int i = 1; i <= 5; i++) for(int i = 1; i <= 5; i++)
{ {
EXPECT_EQ(i, dst.nextObject()); EXPECT_EQ(i, dst.next());
} }
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -253,12 +253,12 @@ TEST(Linq, Creations) ...@@ -253,12 +253,12 @@ TEST(Linq, Creations)
auto dst_vec = from(vec); auto dst_vec = from(vec);
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(ptr, ptr+5);
//auto dst_cptr = from<const int>(cptr, cptr+5); //auto dst_cptr = from(cptr, cptr+5);
auto dst_ptr_length = from<int>(ptr, 5); auto dst_ptr_length = from(ptr, 5);
//auto dst_cptr_length = from<const int>(cptr, 5); //auto dst_cptr_length = from(cptr, 5);
auto dst_vec_iter = from<int>(vec.begin(), vec.end()); auto dst_vec_iter = from(vec.begin(), vec.end());
//auto dst_vec_citer = from<const int>(vec.cbegin(), vec.cend()); //auto dst_vec_citer = from(vec.cbegin(), vec.cend());
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -301,8 +301,8 @@ TEST(Linq, MessagesCountUniqueContacts) ...@@ -301,8 +301,8 @@ TEST(Linq, MessagesCountUniqueContacts)
TEST(Linq, ForwardIterating) TEST(Linq, ForwardIterating)
{ {
std::stringstream stream("0123456789"); std::stringstream stream("0123456789");
auto dst = from<char>(std::istream_iterator<char>(stream), auto dst = from(std::istream_iterator<char>(stream),
std::istream_iterator<char>()) std::istream_iterator<char>())
.where( [](char a){return a % 2 == 0;}) .where( [](char a){return a % 2 == 0;})
.select([](char a){return std::string(1,a);}) .select([](char a){return std::string(1,a);})
.sum(); .sum();
......
...@@ -63,7 +63,7 @@ TEST(OrderByRange, NoElements) ...@@ -63,7 +63,7 @@ TEST(OrderByRange, NoElements)
auto rng = from(src); auto rng = from(src);
auto dst = rng.orderBy(); auto dst = rng.orderBy();
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
......
...@@ -50,7 +50,7 @@ TEST(SkipRange, ManyToZero) ...@@ -50,7 +50,7 @@ TEST(SkipRange, ManyToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skip(6); auto dst = rng.skip(6);
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipRange, ManyToZeroLess) TEST(SkipRange, ManyToZeroLess)
...@@ -60,7 +60,7 @@ TEST(SkipRange, ManyToZeroLess) ...@@ -60,7 +60,7 @@ TEST(SkipRange, ManyToZeroLess)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skip(10); auto dst = rng.skip(10);
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -83,7 +83,7 @@ TEST(SkipRange, OneToZero) ...@@ -83,7 +83,7 @@ TEST(SkipRange, OneToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skip(1); auto dst = rng.skip(1);
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipRange, OneToZeroLess) TEST(SkipRange, OneToZeroLess)
...@@ -93,7 +93,7 @@ TEST(SkipRange, OneToZeroLess) ...@@ -93,7 +93,7 @@ TEST(SkipRange, OneToZeroLess)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skip(2); auto dst = rng.skip(2);
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipRange, ZeroToZero) TEST(SkipRange, ZeroToZero)
...@@ -103,7 +103,7 @@ TEST(SkipRange, ZeroToZero) ...@@ -103,7 +103,7 @@ TEST(SkipRange, ZeroToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skip(0); auto dst = rng.skip(0);
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
TEST(SkipRange, ZeroToZeroLess) TEST(SkipRange, ZeroToZeroLess)
...@@ -113,7 +113,7 @@ TEST(SkipRange, ZeroToZeroLess) ...@@ -113,7 +113,7 @@ TEST(SkipRange, ZeroToZeroLess)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skip(2); auto dst = rng.skip(2);
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -194,7 +194,7 @@ TEST(SkipWhileRange, ManyToZero) ...@@ -194,7 +194,7 @@ TEST(SkipWhileRange, ManyToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile([](int it){return it > 0;}); auto dst = rng.skipWhile([](int it){return it > 0;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipWhileRange_i, ManyToZeroeByIndex) TEST(SkipWhileRange_i, ManyToZeroeByIndex)
...@@ -204,7 +204,7 @@ TEST(SkipWhileRange_i, ManyToZeroeByIndex) ...@@ -204,7 +204,7 @@ TEST(SkipWhileRange_i, ManyToZeroeByIndex)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile_i([](int /*it*/, int idx){return idx < 6;}); auto dst = rng.skipWhile_i([](int /*it*/, int idx){return idx < 6;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipWhileRange_i, ManyToZeroByItemValue) TEST(SkipWhileRange_i, ManyToZeroByItemValue)
...@@ -214,7 +214,7 @@ TEST(SkipWhileRange_i, ManyToZeroByItemValue) ...@@ -214,7 +214,7 @@ TEST(SkipWhileRange_i, ManyToZeroByItemValue)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile_i([](int it, int /*idx*/){return it > 0;}); auto dst = rng.skipWhile_i([](int it, int /*idx*/){return it > 0;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipWhileRange_i, ManyToZeroIndexAndItemValue) TEST(SkipWhileRange_i, ManyToZeroIndexAndItemValue)
...@@ -224,7 +224,7 @@ TEST(SkipWhileRange_i, ManyToZeroIndexAndItemValue) ...@@ -224,7 +224,7 @@ TEST(SkipWhileRange_i, ManyToZeroIndexAndItemValue)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile_i([](int it, int idx){return idx != it;}); auto dst = rng.skipWhile_i([](int it, int idx){return idx != it;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -280,7 +280,7 @@ TEST(SkipWhileRange, OneToZero) ...@@ -280,7 +280,7 @@ TEST(SkipWhileRange, OneToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile([](int it){return it == 5;}); auto dst = rng.skipWhile([](int it){return it == 5;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipWhileRange_i, OneToZeroByIndex) TEST(SkipWhileRange_i, OneToZeroByIndex)
...@@ -290,7 +290,7 @@ TEST(SkipWhileRange_i, OneToZeroByIndex) ...@@ -290,7 +290,7 @@ TEST(SkipWhileRange_i, OneToZeroByIndex)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile_i([](int /*it*/, int idx){return idx < 6;}); auto dst = rng.skipWhile_i([](int /*it*/, int idx){return idx < 6;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipWhileRange_i, OneToZeroByItemValue) TEST(SkipWhileRange_i, OneToZeroByItemValue)
...@@ -300,7 +300,7 @@ TEST(SkipWhileRange_i, OneToZeroByItemValue) ...@@ -300,7 +300,7 @@ TEST(SkipWhileRange_i, OneToZeroByItemValue)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile_i([](int it, int /*idx*/){return it > 0;}); auto dst = rng.skipWhile_i([](int it, int /*idx*/){return it > 0;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipWhileRange_i, OneToZeroIndexAndItemValue) TEST(SkipWhileRange_i, OneToZeroIndexAndItemValue)
...@@ -310,7 +310,7 @@ TEST(SkipWhileRange_i, OneToZeroIndexAndItemValue) ...@@ -310,7 +310,7 @@ TEST(SkipWhileRange_i, OneToZeroIndexAndItemValue)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile_i([](int it, int idx){return idx != it;}); auto dst = rng.skipWhile_i([](int it, int idx){return idx != it;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(SkipWhileRange, ZeroToZero) TEST(SkipWhileRange, ZeroToZero)
...@@ -320,7 +320,7 @@ TEST(SkipWhileRange, ZeroToZero) ...@@ -320,7 +320,7 @@ TEST(SkipWhileRange, ZeroToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile([](int){return false;}); auto dst = rng.skipWhile([](int){return false;});
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
TEST(SkipWhileRange_i, ZeroToZero) TEST(SkipWhileRange_i, ZeroToZero)
...@@ -330,7 +330,7 @@ TEST(SkipWhileRange_i, ZeroToZero) ...@@ -330,7 +330,7 @@ TEST(SkipWhileRange_i, ZeroToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.skipWhile_i([](int /*it*/, int /*idx*/){return true;}); auto dst = rng.skipWhile_i([](int /*it*/, int /*idx*/){return true;});
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -45,8 +45,8 @@ TEST(Sum, BoolSum) ...@@ -45,8 +45,8 @@ TEST(Sum, BoolSum)
src.push_back(4); src.push_back(4);
src.push_back(5); src.push_back(5);
auto rng1 = from(src).sum<int>([](int a){return a%2 == 0;}); auto rng1 = from(src).sum([](int a){return a%2 == 0;});
auto rng2 = from(src).sum<int>([](int a){return a%2 == 1;}); auto rng2 = from(src).sum([](int a){return a%2 == 1;});
EXPECT_EQ(2, rng1); EXPECT_EQ(2, rng1);
EXPECT_EQ(3, rng2); EXPECT_EQ(3, rng2);
......
...@@ -61,7 +61,7 @@ TEST(TakeRange, ManyToZero) ...@@ -61,7 +61,7 @@ TEST(TakeRange, ManyToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.take(0); auto dst = rng.take(0);
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -95,7 +95,7 @@ TEST(TakeRange, OneToZero) ...@@ -95,7 +95,7 @@ TEST(TakeRange, OneToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.take(0); auto dst = rng.take(0);
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(TakeRange, ZeroToZero) TEST(TakeRange, ZeroToZero)
...@@ -105,7 +105,7 @@ TEST(TakeRange, ZeroToZero) ...@@ -105,7 +105,7 @@ TEST(TakeRange, ZeroToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.take(0); auto dst = rng.take(0);
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -193,7 +193,7 @@ TEST(TakeWhileRange, ManyToZero) ...@@ -193,7 +193,7 @@ TEST(TakeWhileRange, ManyToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile([](int it){return it < 0;}); auto dst = rng.takeWhile([](int it){return it < 0;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(TakeWhileRange_i, ManyToZeroByIndex) TEST(TakeWhileRange_i, ManyToZeroByIndex)
...@@ -203,7 +203,7 @@ TEST(TakeWhileRange_i, ManyToZeroByIndex) ...@@ -203,7 +203,7 @@ TEST(TakeWhileRange_i, ManyToZeroByIndex)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile_i([](int /*it*/, int idx){return idx > 0;}); auto dst = rng.takeWhile_i([](int /*it*/, int idx){return idx > 0;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(TakeWhileRange_i, ManyToZeroByItemValue) TEST(TakeWhileRange_i, ManyToZeroByItemValue)
...@@ -213,7 +213,7 @@ TEST(TakeWhileRange_i, ManyToZeroByItemValue) ...@@ -213,7 +213,7 @@ TEST(TakeWhileRange_i, ManyToZeroByItemValue)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile_i([](int it, int /*idx*/){return it > 2;}); auto dst = rng.takeWhile_i([](int it, int /*idx*/){return it > 2;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(TakeWhileRange_i, ManyToZeroByIdexAndItemValue) TEST(TakeWhileRange_i, ManyToZeroByIdexAndItemValue)
...@@ -223,7 +223,7 @@ TEST(TakeWhileRange_i, ManyToZeroByIdexAndItemValue) ...@@ -223,7 +223,7 @@ TEST(TakeWhileRange_i, ManyToZeroByIdexAndItemValue)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile_i([](int it, int idx){return it < 0 || idx > 0;}); auto dst = rng.takeWhile_i([](int it, int idx){return it < 0 || idx > 0;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -279,7 +279,7 @@ TEST(TakeWhileRange, OneToZero) ...@@ -279,7 +279,7 @@ TEST(TakeWhileRange, OneToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile([](int){return false;}); auto dst = rng.takeWhile([](int){return false;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(TakeWhileRange_i, OneToZeroByIndex) TEST(TakeWhileRange_i, OneToZeroByIndex)
...@@ -289,7 +289,7 @@ TEST(TakeWhileRange_i, OneToZeroByIndex) ...@@ -289,7 +289,7 @@ TEST(TakeWhileRange_i, OneToZeroByIndex)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile_i([](int /*it*/, int idx){return idx > 0;}); auto dst = rng.takeWhile_i([](int /*it*/, int idx){return idx > 0;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(TakeWhileRange_i, OneToZeroByItemValue) TEST(TakeWhileRange_i, OneToZeroByItemValue)
...@@ -299,7 +299,7 @@ TEST(TakeWhileRange_i, OneToZeroByItemValue) ...@@ -299,7 +299,7 @@ TEST(TakeWhileRange_i, OneToZeroByItemValue)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile_i([](int it, int /*idx*/){return it < 5;}); auto dst = rng.takeWhile_i([](int it, int /*idx*/){return it < 5;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(TakeWhileRange_i, OneToZeroByIndexAndItemValue) TEST(TakeWhileRange_i, OneToZeroByIndexAndItemValue)
...@@ -309,7 +309,7 @@ TEST(TakeWhileRange_i, OneToZeroByIndexAndItemValue) ...@@ -309,7 +309,7 @@ TEST(TakeWhileRange_i, OneToZeroByIndexAndItemValue)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile_i([](int it, int idx){return idx == 0 && it > 5;}); auto dst = rng.takeWhile_i([](int it, int idx){return idx == 0 && it > 5;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(TakeWhileRange, ZeroToZero) TEST(TakeWhileRange, ZeroToZero)
...@@ -319,7 +319,7 @@ TEST(TakeWhileRange, ZeroToZero) ...@@ -319,7 +319,7 @@ TEST(TakeWhileRange, ZeroToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile([](int){return false;}); auto dst = rng.takeWhile([](int){return false;});
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
TEST(TakeWhileRange_i, ZeroToZero) TEST(TakeWhileRange_i, ZeroToZero)
...@@ -329,7 +329,7 @@ TEST(TakeWhileRange_i, ZeroToZero) ...@@ -329,7 +329,7 @@ TEST(TakeWhileRange_i, ZeroToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.takeWhile_i([](int /*it*/, int /*idx*/){return false;}); auto dst = rng.takeWhile_i([](int /*it*/, int /*idx*/){return false;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
using namespace boolinq; using namespace boolinq;
TEST(ToDeque, Deque2Deque) TEST(toStdDeque, Deque2Deque)
{ {
std::deque<int> src; std::deque<int> src;
src.push_back(100); src.push_back(100);
...@@ -14,7 +14,7 @@ TEST(ToDeque, Deque2Deque) ...@@ -14,7 +14,7 @@ TEST(ToDeque, Deque2Deque)
src.push_back(300); src.push_back(300);
auto rng = from(src); auto rng = from(src);
auto dst = rng.toDeque(); auto dst = rng.toStdDeque();
EXPECT_EQ(dst,src); EXPECT_EQ(dst,src);
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
using namespace boolinq; using namespace boolinq;
TEST(ToList, List2List) TEST(toStdList, List2List)
{ {
std::list<int> src; std::list<int> src;
src.push_back(100); src.push_back(100);
...@@ -14,7 +14,7 @@ TEST(ToList, List2List) ...@@ -14,7 +14,7 @@ TEST(ToList, List2List)
src.push_back(300); src.push_back(300);
auto rng = from(src); auto rng = from(src);
auto dst = rng.toList(); auto dst = rng.toStdList();
EXPECT_EQ(dst,src); EXPECT_EQ(dst,src);
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
using namespace boolinq; using namespace boolinq;
TEST(ToSet, Vector2Set) TEST(toStdSet, Vector2Set)
{ {
std::vector<int> src; std::vector<int> src;
src.push_back(1); src.push_back(1);
...@@ -16,7 +16,7 @@ TEST(ToSet, Vector2Set) ...@@ -16,7 +16,7 @@ TEST(ToSet, Vector2Set)
src.push_back(2); src.push_back(2);
auto rng = from(src); auto rng = from(src);
auto dst = rng.toSet(); auto dst = rng.toStdSet();
EXPECT_EQ(3U, dst.size()); EXPECT_EQ(3U, dst.size());
EXPECT_NE(dst.end(), dst.find(1)); EXPECT_NE(dst.end(), dst.find(1));
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
using namespace boolinq; using namespace boolinq;
TEST(ToVector, Vector2Vector) TEST(toStdVector, Vector2Vector)
{ {
std::vector<int> src; std::vector<int> src;
src.push_back(100); src.push_back(100);
...@@ -14,7 +14,7 @@ TEST(ToVector, Vector2Vector) ...@@ -14,7 +14,7 @@ TEST(ToVector, Vector2Vector)
src.push_back(300); src.push_back(300);
auto rng = from(src); auto rng = from(src);
auto dst = rng.toVector(); auto dst = rng.toStdVector();
EXPECT_EQ(dst,src); EXPECT_EQ(dst,src);
} }
...@@ -99,5 +99,5 @@ TEST(UnbytesRange, EmptyDefault) ...@@ -99,5 +99,5 @@ TEST(UnbytesRange, EmptyDefault)
auto rng = from(src); auto rng = from(src);
auto dst = rng.unbytes<int>(); auto dst = rng.unbytes<int>();
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
...@@ -17,7 +17,7 @@ TEST(WhereRange, IntOdd) ...@@ -17,7 +17,7 @@ TEST(WhereRange, IntOdd)
auto rng = from(src); auto rng = from(src);
auto dst = rng.where([](int a){return a%2 == 1;}); auto dst = rng.where([](int a){return a%2 == 1;});
CheckRangeEqArray(dst, ans); CheckRangeEqArray(dst, ans);
} }
...@@ -42,7 +42,7 @@ TEST(WhereRange, FirstLetterFront) ...@@ -42,7 +42,7 @@ TEST(WhereRange, FirstLetterFront)
auto rng = from(src); auto rng = from(src);
auto dst = rng.where([](std::string a){return a[0] == 'a';}); auto dst = rng.where([](std::string a){return a[0] == 'a';});
CheckRangeEqArray(dst, ans); CheckRangeEqArray(dst, ans);
} }
...@@ -73,17 +73,17 @@ TEST(WhereRange, NameAgeLess) ...@@ -73,17 +73,17 @@ TEST(WhereRange, NameAgeLess)
auto rng = from(src); auto rng = from(src);
auto dst = rng.where([](const NameAge & a){return a.age < 18;}); auto dst = rng.where([](const NameAge & a){return a.age < 18;});
CheckRangeEqArray(dst, ans, [](const NameAge & a){return a.name;}); CheckRangeEqArray(dst, ans, [](const NameAge & a){return a.name;});
} }
////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
TEST(WhereRange, MayToOne) TEST(WhereRange, MayToOne)
{ {
int src[] = {0,1,2}; int src[] = {0,1,2};
int ans[] = {1}; int ans[] = {1};
auto rng = from(src); auto rng = from(src);
auto dst = rng.where([](int a){return a == 1;}); auto dst = rng.where([](int a){return a == 1;});
...@@ -104,21 +104,21 @@ TEST(WhereRange, OneToOne) ...@@ -104,21 +104,21 @@ TEST(WhereRange, OneToOne)
TEST(WhereRange, ManyToZero) TEST(WhereRange, ManyToZero)
{ {
int src[] = {0,1,2}; int src[] = {0,1,2};
auto rng = from(src); auto rng = from(src);
auto dst = rng.where([](int a){return a == 5;}); auto dst = rng.where([](int a){return a == 5;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(WhereRange, OneToZero) TEST(WhereRange, OneToZero)
{ {
int src[] = {5}; int src[] = {5};
auto rng = from(src); auto rng = from(src);
auto dst = rng.where( [](int a){return a>10;}); auto dst = rng.where( [](int a){return a>10;});
EXPECT_THROW(dst.nextObject(), LinqEndException); EXPECT_THROW(dst.next(), LinqEndException);
} }
TEST(WhereRange, ZeroToZero) TEST(WhereRange, ZeroToZero)
...@@ -128,5 +128,5 @@ TEST(WhereRange, ZeroToZero) ...@@ -128,5 +128,5 @@ TEST(WhereRange, ZeroToZero)
auto rng = from(src); auto rng = from(src);
auto dst = rng.where( [](int a){return a>0;}); auto dst = rng.where( [](int a){return a>0;});
EXPECT_THROW(rng.nextObject(), LinqEndException); EXPECT_THROW(rng.next(), LinqEndException);
} }
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