Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
boolinq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
boolinq
Commits
89aabe3b
Commit
89aabe3b
authored
Jun 28, 2019
by
Anton Bukov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some issues
parent
ecab6f46
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
124 additions
and
120 deletions
+124
-120
README.md
README.md
+17
-13
boolinq.h
include/boolinq/boolinq.h
+0
-0
boolinq_old.h
include/boolinq/boolinq_old.h
+0
-0
CommonTests.h
test/CommonTests.h
+5
-5
GroupByRangeTest.cpp
test/GroupByRangeTest.cpp
+3
-3
IterRangeTest.cpp
test/IterRangeTest.cpp
+25
-25
LinqTest.cpp
test/LinqTest.cpp
+23
-23
OrderByRangeTest.cpp
test/OrderByRangeTest.cpp
+1
-1
SkipRangeTest.cpp
test/SkipRangeTest.cpp
+6
-6
SkipWhileRangeTest.cpp
test/SkipWhileRangeTest.cpp
+10
-10
SumTest.cpp
test/SumTest.cpp
+2
-2
TakeRangeTest.cpp
test/TakeRangeTest.cpp
+3
-3
TakeWhileRangeTest.cpp
test/TakeWhileRangeTest.cpp
+10
-10
ToDequeTest.cpp
test/ToDequeTest.cpp
+2
-2
ToListTest.cpp
test/ToListTest.cpp
+2
-2
ToSetTest.cpp
test/ToSetTest.cpp
+2
-2
ToVectorTest.cpp
test/ToVectorTest.cpp
+2
-2
UnbytesRangeTest.cpp
test/UnbytesRangeTest.cpp
+1
-1
WhereRangeTest.cpp
test/WhereRangeTest.cpp
+10
-10
No files found.
README.md
View file @
89aabe3b
...
...
@@ -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
.
select
([](
int
a
){
return
a
*
2
;})
// 2,6,10,14
.
where
(
[](
int
a
){
return
a
>
2
&&
a
<
12
;})
// 6,10
.
toVector
();
.
to
Std
Vector
();
// dst type: std::vector<int>
// dst items: 6,10
...
...
@@ -45,7 +45,7 @@ Man src[] =
auto
dst
=
from
(
src
).
where
(
[](
const
Man
&
man
){
return
man
.
age
<
18
;})
.
orderBy
([](
const
Man
&
man
){
return
man
.
age
;})
.
select
(
[](
const
Man
&
man
){
return
man
.
name
;})
.
toVector
();
.
to
Std
Vector
();
// dst type: std::vector<std::string>
// dst items: "Kevin", "Layer", "Agata"
...
...
@@ -90,14 +90,20 @@ int DenisUniqueContactCount =
-
cast
<
T
>
()
-
take(int)
-
takeWhile(int)
-
takeWhile_i(int)
-
skip(int)
-
skipWhile(int)
-
skipWhile_i(int)
-
concat(range)
-
where(lambda)
-
where_i(lambda)
-
select(lambda)
-
select_i(lambda)
-
selectMany(lambda)
-
reverse()
-
orderBy()
-
orderBy(lambda)
-
groupBy(lambda)
-
distinct()
-
distinct(lambda)
-
for_each(lambda)
...
...
@@ -114,14 +120,16 @@ int DenisUniqueContactCount =
-
max()
-
max(lambda)
-
count()
-
count(lambda)
-
contains(value)
-
elementAt(int)
-
toSet()
-
toList()
-
toDeque()
-
toVector()
-
toContainer
<
T
>
()
-
toStdSet()
-
toStdList()
-
toStdDeque()
-
toStdVector()
#### Coming soon:
-
groupBy(lambda)
#### Custom:
...
...
@@ -138,10 +146,6 @@ int DenisUniqueContactCount =
-
unbits
<
T,BitOrder
>
()
-
unbits
<
T,BitOrder,ByteOrder
>
()
#### Coming soon:
-
selectMany(lambda)
#### May be will be:
-
gz()
...
...
include/boolinq/boolinq.h
View file @
89aabe3b
This diff is collapsed.
Click to expand it.
include/boolinq/boolinq_old.h
View file @
89aabe3b
This diff is collapsed.
Click to expand it.
test/CommonTests.h
View file @
89aabe3b
...
...
@@ -14,18 +14,18 @@ template<typename R, typename T, unsigned N, typename F>
void
CheckRangeEqArray
(
R
dst
,
T
(
&
ans
)[
N
],
F
f
)
{
for
(
unsigned
i
=
0
;
i
<
N
;
i
++
)
EXPECT_EQ
(
f
(
ans
[
i
]),
f
(
dst
.
next
Object
()));
EXPECT_EQ
(
f
(
ans
[
i
]),
f
(
dst
.
next
()));
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
template
<
typename
R
,
typename
T
,
unsigned
N
>
void
CheckRangeEqArray
(
R
dst
,
T
(
&
ans
)[
N
])
{
for
(
unsigned
i
=
0
;
i
<
N
;
i
++
)
EXPECT_EQ
(
ans
[
i
],
dst
.
next
Object
());
EXPECT_EQ
(
ans
[
i
],
dst
.
next
());
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
template
<
typename
T
,
unsigned
N
>
...
...
@@ -44,7 +44,7 @@ template<typename R, typename T, unsigned N>
void
CheckRangeEqSet
(
R
dst
,
T
(
&
ans
)[
N
])
{
std
::
set
<
T
>
expected
=
ArrayToSet
(
ans
);
std
::
set
<
typename
R
::
value_type
>
actual
=
dst
.
toSet
();
std
::
set
<
typename
R
::
value_type
>
actual
=
dst
.
toS
tdS
et
();
EXPECT_EQ
(
expected
.
size
(),
actual
.
size
());
...
...
test/GroupByRangeTest.cpp
View file @
89aabe3b
...
...
@@ -41,7 +41,7 @@ TEST(GroupByRange, IntsFront)
CheckRangeEqArray(dst.back(), ans_0);
CheckRangeEqArray(dst.popFront(), ans_0);
EXPECT_THROW(dst.next
Object
(), LinqEndException);
EXPECT_THROW(dst.next(), LinqEndException);
}
TEST(GroupByRange, IntsBack)
...
...
@@ -73,7 +73,7 @@ TEST(GroupByRange, IntsBack)
CheckRangeEqArray(dst.back(), ans_1);
CheckRangeEqArray(dst.popBack(), ans_1);
EXPECT_THROW(dst.next
Object
(), LinqEndException);
EXPECT_THROW(dst.next(), LinqEndException);
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -126,7 +126,7 @@ TEST(GroupByRange, CountChildrenByAge)
CheckRangeEqArray(dst.back(), ans_true);
CheckRangeEqArray(dst.popFront(), ans_true);
EXPECT_THROW(dst.next
Object
(), LinqEndException);
EXPECT_THROW(dst.next(), LinqEndException);
}
*/
test/IterRangeTest.cpp
View file @
89aabe3b
...
...
@@ -27,8 +27,8 @@ TEST(IterRange, ListInt)
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
CheckRangeEqArray
(
from
(
lst
),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
lst
.
begin
(),
lst
.
end
()),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
lst
.
cbegin
(),
lst
.
cend
()),
ans
);
CheckRangeEqArray
(
from
(
lst
.
begin
(),
lst
.
end
()),
ans
);
CheckRangeEqArray
(
from
(
lst
.
cbegin
(),
lst
.
cend
()),
ans
);
}
TEST
(
IterRange
,
DequeInt
)
...
...
@@ -43,8 +43,8 @@ TEST(IterRange, DequeInt)
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
CheckRangeEqArray
(
from
(
dck
),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
dck
.
begin
(),
dck
.
end
()),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
dck
.
cbegin
(),
dck
.
cend
()),
ans
);
CheckRangeEqArray
(
from
(
dck
.
begin
(),
dck
.
end
()),
ans
);
CheckRangeEqArray
(
from
(
dck
.
cbegin
(),
dck
.
cend
()),
ans
);
}
TEST
(
IterRange
,
VectorInt
)
...
...
@@ -59,8 +59,8 @@ TEST(IterRange, VectorInt)
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
CheckRangeEqArray
(
from
(
vec
),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
vec
.
begin
(),
vec
.
end
()),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
vec
.
cbegin
(),
vec
.
cend
()),
ans
);
CheckRangeEqArray
(
from
(
vec
.
begin
(),
vec
.
end
()),
ans
);
CheckRangeEqArray
(
from
(
vec
.
cbegin
(),
vec
.
cend
()),
ans
);
}
TEST
(
IterRange
,
SetInt
)
...
...
@@ -69,22 +69,22 @@ TEST(IterRange, SetInt)
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
CheckRangeEqSet
(
from
(
set
),
ans
);
CheckRangeEqSet
(
from
<
int
>
(
set
.
begin
(),
set
.
end
()),
ans
);
CheckRangeEqSet
(
from
<
int
>
(
set
.
cbegin
(),
set
.
cend
()),
ans
);
CheckRangeEqSet
(
from
(
set
.
begin
(),
set
.
end
()),
ans
);
CheckRangeEqSet
(
from
(
set
.
cbegin
(),
set
.
cend
()),
ans
);
}
TEST
(
IterRange
,
MapInt
)
{
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
}};
CheckRangeEqArray
(
from
(
map
)
.
orderBy
([](
std
::
pair
<
int
,
int
>
p
){
return
p
.
second
;
}),
ans
);
CheckRangeEqArray
(
from
<
std
::
pair
<
int
,
int
>
>
(
map
.
begin
(),
map
.
end
())
.
orderBy
([](
std
::
pair
<
int
,
int
>
p
){
return
p
.
second
;
}),
ans
);
CheckRangeEqArray
(
from
<
std
::
pair
<
int
,
int
>
>
(
map
.
cbegin
(),
map
.
cend
())
.
orderBy
([](
std
::
pair
<
int
,
int
>
p
){
return
p
.
second
;
}),
ans
);
}
//
TEST(IterRange, MapInt)
//
{
//
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}};
//
//
CheckRangeEqArray(from(map)
//
.orderBy([](std::pair<int,int> p){ return p.second; }), ans);
// CheckRangeEqArray(from
(map.begin(), map.end())
//
.orderBy([](std::pair<int,int> p){ return p.second; }), ans);
// CheckRangeEqArray(from
(map.cbegin(), map.cend())
//
.orderBy([](std::pair<int,int> p){ return p.second; }), ans);
//
}
TEST
(
IterRange
,
StdArrayInt
)
{
...
...
@@ -92,8 +92,8 @@ TEST(IterRange, StdArrayInt)
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
CheckRangeEqArray
(
from
(
arr
),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
arr
.
begin
(),
arr
.
end
()),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
arr
.
cbegin
(),
arr
.
cend
()),
ans
);
CheckRangeEqArray
(
from
(
arr
.
begin
(),
arr
.
end
()),
ans
);
CheckRangeEqArray
(
from
(
arr
.
cbegin
(),
arr
.
cend
()),
ans
);
}
TEST
(
IterRange
,
ArrayInt
)
...
...
@@ -104,8 +104,8 @@ TEST(IterRange, ArrayInt)
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
CheckRangeEqArray
(
from
(
arr
),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
ptr
,
5
),
ans
);
CheckRangeEqArray
(
from
<
int
>
(
ptr
,
ptr
+
5
),
ans
);
CheckRangeEqArray
(
from
(
ptr
,
5
),
ans
);
CheckRangeEqArray
(
from
(
ptr
,
ptr
+
5
),
ans
);
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -126,5 +126,5 @@ TEST(IterRange, EmptyVector)
auto
rng
=
from
(
src
);
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
test/LinqTest.cpp
View file @
89aabe3b
...
...
@@ -25,10 +25,10 @@ TEST(Linq, WhereOdd)
for
(
int
i
=
1
;
i
<=
5
;
i
+=
2
)
{
EXPECT_EQ
(
i
,
rng
.
next
Object
());
EXPECT_EQ
(
i
,
rng
.
next
());
}
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
TEST
(
Linq
,
WhereOdd_WhereLess
)
...
...
@@ -48,10 +48,10 @@ TEST(Linq, WhereOdd_WhereLess)
for
(
int
i
=
1
;
i
<=
3
;
i
+=
2
)
{
EXPECT_EQ
(
i
,
rng
.
next
Object
());
EXPECT_EQ
(
i
,
rng
.
next
());
}
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
TEST
(
Linq
,
WhereLess_WhereOdd
)
...
...
@@ -68,7 +68,7 @@ TEST(Linq, WhereLess_WhereOdd)
auto
rng
=
from
(
src
).
where
([](
int
a
){
return
a
<
4
;})
.
where
([](
int
a
){
return
a
%
2
==
1
;})
.
toVector
();
.
to
Std
Vector
();
std
::
vector
<
int
>
ans
;
ans
.
push_back
(
1
);
...
...
@@ -92,7 +92,7 @@ TEST(Linq, WhereLess_WhereOdd_OrderByDesc)
auto
rng
=
from
(
src
).
where
([](
int
a
){
return
a
<
6
;})
.
where
([](
int
a
){
return
a
%
2
==
1
;})
.
orderBy
([](
int
a
){
return
-
a
;})
.
toVector
();
.
to
Std
Vector
();
std
::
vector
<
int
>
ans
;
ans
.
push_back
(
5
);
...
...
@@ -115,7 +115,7 @@ TEST(Linq, WhereOdd_ToVector)
src
.
push_back
(
8
);
auto
dst
=
from
(
src
).
where
([](
int
a
){
return
a
%
2
==
1
;})
.
toVector
();
.
to
Std
Vector
();
std
::
vector
<
int
>
ans
;
ans
.
push_back
(
1
);
...
...
@@ -141,7 +141,7 @@ TEST(Linq, WhereOdd_WhereLess_SelectMul2_ToVector)
auto
dst
=
from
(
src
).
where
([](
int
a
){
return
a
%
2
==
1
;})
.
where
([](
int
a
){
return
a
<
6
;})
.
select
([](
int
a
){
return
a
*
2
;})
.
toVector
();
.
to
Std
Vector
();
std
::
vector
<
int
>
ans
;
ans
.
push_back
(
2
);
...
...
@@ -167,7 +167,7 @@ TEST(Linq, WhereOdd_WhereLess_SelectMul2_Reverse_ToVector)
.
where
([](
int
a
){
return
a
<
6
;})
.
select
([](
int
a
){
return
a
*
2
;})
.
reverse
()
.
toVector
();
.
to
Std
Vector
();
std
::
vector
<
int
>
ans
;
ans
.
push_back
(
10
);
...
...
@@ -193,7 +193,7 @@ TEST(Linq, WhereOdd_Reverse_Reverse)
.
reverse
()
.
where
([](
int
a
){
return
a
<
4
;})
.
reverse
()
.
toVector
();
.
to
Std
Vector
();
std
::
vector
<
int
>
ans
;
ans
.
push_back
(
1
);
...
...
@@ -208,14 +208,14 @@ TEST(Linq, Pointer_Front)
{
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
++
)
{
EXPECT_EQ
(
i
,
dst
.
next
Object
());
EXPECT_EQ
(
i
,
dst
.
next
());
}
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
...
...
@@ -229,10 +229,10 @@ TEST(Linq, Array_Front)
for
(
int
i
=
1
;
i
<=
5
;
i
++
)
{
EXPECT_EQ
(
i
,
dst
.
next
Object
());
EXPECT_EQ
(
i
,
dst
.
next
());
}
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -253,12 +253,12 @@ TEST(Linq, Creations)
auto
dst_vec
=
from
(
vec
);
auto
dst_arr
=
from
(
arr
);
//auto dst_carr = from(carr);
auto
dst_ptr
=
from
<
int
>
(
ptr
,
ptr
+
5
);
//auto dst_cptr = from
<const int>
(cptr, cptr+5);
auto
dst_ptr_length
=
from
<
int
>
(
ptr
,
5
);
//auto dst_cptr_length = from
<const int>
(cptr, 5);
auto
dst_vec_iter
=
from
<
int
>
(
vec
.
begin
(),
vec
.
end
());
//auto dst_vec_citer = from
<const int>
(vec.cbegin(), vec.cend());
auto
dst_ptr
=
from
(
ptr
,
ptr
+
5
);
//auto dst_cptr = from(cptr, cptr+5);
auto
dst_ptr_length
=
from
(
ptr
,
5
);
//auto dst_cptr_length = from(cptr, 5);
auto
dst_vec_iter
=
from
(
vec
.
begin
(),
vec
.
end
());
//auto dst_vec_citer = from(vec.cbegin(), vec.cend());
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -301,8 +301,8 @@ TEST(Linq, MessagesCountUniqueContacts)
TEST
(
Linq
,
ForwardIterating
)
{
std
::
stringstream
stream
(
"0123456789"
);
auto
dst
=
from
<
char
>
(
std
::
istream_iterator
<
char
>
(
stream
),
std
::
istream_iterator
<
char
>
())
auto
dst
=
from
(
std
::
istream_iterator
<
char
>
(
stream
),
std
::
istream_iterator
<
char
>
())
.
where
(
[](
char
a
){
return
a
%
2
==
0
;})
.
select
([](
char
a
){
return
std
::
string
(
1
,
a
);})
.
sum
();
...
...
test/OrderByRangeTest.cpp
View file @
89aabe3b
...
...
@@ -63,7 +63,7 @@ TEST(OrderByRange, NoElements)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
orderBy
();
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
...
...
test/SkipRangeTest.cpp
View file @
89aabe3b
...
...
@@ -50,7 +50,7 @@ TEST(SkipRange, ManyToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skip
(
6
);
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipRange
,
ManyToZeroLess
)
...
...
@@ -60,7 +60,7 @@ TEST(SkipRange, ManyToZeroLess)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skip
(
10
);
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -83,7 +83,7 @@ TEST(SkipRange, OneToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skip
(
1
);
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipRange
,
OneToZeroLess
)
...
...
@@ -93,7 +93,7 @@ TEST(SkipRange, OneToZeroLess)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skip
(
2
);
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipRange
,
ZeroToZero
)
...
...
@@ -103,7 +103,7 @@ TEST(SkipRange, ZeroToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skip
(
0
);
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
TEST
(
SkipRange
,
ZeroToZeroLess
)
...
...
@@ -113,7 +113,7 @@ TEST(SkipRange, ZeroToZeroLess)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skip
(
2
);
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
test/SkipWhileRangeTest.cpp
View file @
89aabe3b
...
...
@@ -194,7 +194,7 @@ TEST(SkipWhileRange, ManyToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile
([](
int
it
){
return
it
>
0
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipWhileRange_i
,
ManyToZeroeByIndex
)
...
...
@@ -204,7 +204,7 @@ TEST(SkipWhileRange_i, ManyToZeroeByIndex)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile_i
([](
int
/*it*/
,
int
idx
){
return
idx
<
6
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipWhileRange_i
,
ManyToZeroByItemValue
)
...
...
@@ -214,7 +214,7 @@ TEST(SkipWhileRange_i, ManyToZeroByItemValue)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile_i
([](
int
it
,
int
/*idx*/
){
return
it
>
0
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipWhileRange_i
,
ManyToZeroIndexAndItemValue
)
...
...
@@ -224,7 +224,7 @@ TEST(SkipWhileRange_i, ManyToZeroIndexAndItemValue)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile_i
([](
int
it
,
int
idx
){
return
idx
!=
it
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -280,7 +280,7 @@ TEST(SkipWhileRange, OneToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile
([](
int
it
){
return
it
==
5
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipWhileRange_i
,
OneToZeroByIndex
)
...
...
@@ -290,7 +290,7 @@ TEST(SkipWhileRange_i, OneToZeroByIndex)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile_i
([](
int
/*it*/
,
int
idx
){
return
idx
<
6
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipWhileRange_i
,
OneToZeroByItemValue
)
...
...
@@ -300,7 +300,7 @@ TEST(SkipWhileRange_i, OneToZeroByItemValue)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile_i
([](
int
it
,
int
/*idx*/
){
return
it
>
0
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipWhileRange_i
,
OneToZeroIndexAndItemValue
)
...
...
@@ -310,7 +310,7 @@ TEST(SkipWhileRange_i, OneToZeroIndexAndItemValue)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile_i
([](
int
it
,
int
idx
){
return
idx
!=
it
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
SkipWhileRange
,
ZeroToZero
)
...
...
@@ -320,7 +320,7 @@ TEST(SkipWhileRange, ZeroToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile
([](
int
){
return
false
;});
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
TEST
(
SkipWhileRange_i
,
ZeroToZero
)
...
...
@@ -330,7 +330,7 @@ TEST(SkipWhileRange_i, ZeroToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
skipWhile_i
([](
int
/*it*/
,
int
/*idx*/
){
return
true
;});
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
test/SumTest.cpp
View file @
89aabe3b
...
...
@@ -45,8 +45,8 @@ TEST(Sum, BoolSum)
src
.
push_back
(
4
);
src
.
push_back
(
5
);
auto
rng1
=
from
(
src
).
sum
<
int
>
([](
int
a
){
return
a
%
2
==
0
;});
auto
rng2
=
from
(
src
).
sum
<
int
>
([](
int
a
){
return
a
%
2
==
1
;});
auto
rng1
=
from
(
src
).
sum
([](
int
a
){
return
a
%
2
==
0
;});
auto
rng2
=
from
(
src
).
sum
([](
int
a
){
return
a
%
2
==
1
;});
EXPECT_EQ
(
2
,
rng1
);
EXPECT_EQ
(
3
,
rng2
);
...
...
test/TakeRangeTest.cpp
View file @
89aabe3b
...
...
@@ -61,7 +61,7 @@ TEST(TakeRange, ManyToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
take
(
0
);
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -95,7 +95,7 @@ TEST(TakeRange, OneToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
take
(
0
);
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
TakeRange
,
ZeroToZero
)
...
...
@@ -105,7 +105,7 @@ TEST(TakeRange, ZeroToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
take
(
0
);
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
test/TakeWhileRangeTest.cpp
View file @
89aabe3b
...
...
@@ -193,7 +193,7 @@ TEST(TakeWhileRange, ManyToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile
([](
int
it
){
return
it
<
0
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
TakeWhileRange_i
,
ManyToZeroByIndex
)
...
...
@@ -203,7 +203,7 @@ TEST(TakeWhileRange_i, ManyToZeroByIndex)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile_i
([](
int
/*it*/
,
int
idx
){
return
idx
>
0
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
TakeWhileRange_i
,
ManyToZeroByItemValue
)
...
...
@@ -213,7 +213,7 @@ TEST(TakeWhileRange_i, ManyToZeroByItemValue)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile_i
([](
int
it
,
int
/*idx*/
){
return
it
>
2
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
TakeWhileRange_i
,
ManyToZeroByIdexAndItemValue
)
...
...
@@ -223,7 +223,7 @@ TEST(TakeWhileRange_i, ManyToZeroByIdexAndItemValue)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile_i
([](
int
it
,
int
idx
){
return
it
<
0
||
idx
>
0
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -279,7 +279,7 @@ TEST(TakeWhileRange, OneToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile
([](
int
){
return
false
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
TakeWhileRange_i
,
OneToZeroByIndex
)
...
...
@@ -289,7 +289,7 @@ TEST(TakeWhileRange_i, OneToZeroByIndex)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile_i
([](
int
/*it*/
,
int
idx
){
return
idx
>
0
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
TakeWhileRange_i
,
OneToZeroByItemValue
)
...
...
@@ -299,7 +299,7 @@ TEST(TakeWhileRange_i, OneToZeroByItemValue)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile_i
([](
int
it
,
int
/*idx*/
){
return
it
<
5
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
TakeWhileRange_i
,
OneToZeroByIndexAndItemValue
)
...
...
@@ -309,7 +309,7 @@ TEST(TakeWhileRange_i, OneToZeroByIndexAndItemValue)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile_i
([](
int
it
,
int
idx
){
return
idx
==
0
&&
it
>
5
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
TakeWhileRange
,
ZeroToZero
)
...
...
@@ -319,7 +319,7 @@ TEST(TakeWhileRange, ZeroToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile
([](
int
){
return
false
;});
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
TEST
(
TakeWhileRange_i
,
ZeroToZero
)
...
...
@@ -329,7 +329,7 @@ TEST(TakeWhileRange_i, ZeroToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile_i
([](
int
/*it*/
,
int
/*idx*/
){
return
false
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
//////////////////////////////////////////////////////////////////////////
test/ToDequeTest.cpp
View file @
89aabe3b
...
...
@@ -6,7 +6,7 @@
using
namespace
boolinq
;
TEST
(
To
Deque
,
Deque2Deque
)
TEST
(
toStd
Deque
,
Deque2Deque
)
{
std
::
deque
<
int
>
src
;
src
.
push_back
(
100
);
...
...
@@ -14,7 +14,7 @@ TEST(ToDeque, Deque2Deque)
src
.
push_back
(
300
);
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
toDeque
();
auto
dst
=
rng
.
to
Std
Deque
();
EXPECT_EQ
(
dst
,
src
);
}
test/ToListTest.cpp
View file @
89aabe3b
...
...
@@ -6,7 +6,7 @@
using
namespace
boolinq
;
TEST
(
To
List
,
List2List
)
TEST
(
toStd
List
,
List2List
)
{
std
::
list
<
int
>
src
;
src
.
push_back
(
100
);
...
...
@@ -14,7 +14,7 @@ TEST(ToList, List2List)
src
.
push_back
(
300
);
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
toList
();
auto
dst
=
rng
.
to
Std
List
();
EXPECT_EQ
(
dst
,
src
);
}
test/ToSetTest.cpp
View file @
89aabe3b
...
...
@@ -6,7 +6,7 @@
using
namespace
boolinq
;
TEST
(
To
Set
,
Vector2Set
)
TEST
(
toStd
Set
,
Vector2Set
)
{
std
::
vector
<
int
>
src
;
src
.
push_back
(
1
);
...
...
@@ -16,7 +16,7 @@ TEST(ToSet, Vector2Set)
src
.
push_back
(
2
);
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
toSet
();
auto
dst
=
rng
.
toS
tdS
et
();
EXPECT_EQ
(
3U
,
dst
.
size
());
EXPECT_NE
(
dst
.
end
(),
dst
.
find
(
1
));
...
...
test/ToVectorTest.cpp
View file @
89aabe3b
...
...
@@ -6,7 +6,7 @@
using
namespace
boolinq
;
TEST
(
To
Vector
,
Vector2Vector
)
TEST
(
toStd
Vector
,
Vector2Vector
)
{
std
::
vector
<
int
>
src
;
src
.
push_back
(
100
);
...
...
@@ -14,7 +14,7 @@ TEST(ToVector, Vector2Vector)
src
.
push_back
(
300
);
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
toVector
();
auto
dst
=
rng
.
to
Std
Vector
();
EXPECT_EQ
(
dst
,
src
);
}
test/UnbytesRangeTest.cpp
View file @
89aabe3b
...
...
@@ -99,5 +99,5 @@ TEST(UnbytesRange, EmptyDefault)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
unbytes
<
int
>
();
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
test/WhereRangeTest.cpp
View file @
89aabe3b
...
...
@@ -17,7 +17,7 @@ TEST(WhereRange, IntOdd)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
where
([](
int
a
){
return
a
%
2
==
1
;});
CheckRangeEqArray
(
dst
,
ans
);
}
...
...
@@ -42,7 +42,7 @@ TEST(WhereRange, FirstLetterFront)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
where
([](
std
::
string
a
){
return
a
[
0
]
==
'a'
;});
CheckRangeEqArray
(
dst
,
ans
);
}
...
...
@@ -73,17 +73,17 @@ TEST(WhereRange, NameAgeLess)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
where
([](
const
NameAge
&
a
){
return
a
.
age
<
18
;});
CheckRangeEqArray
(
dst
,
ans
,
[](
const
NameAge
&
a
){
return
a
.
name
;});
}
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
TEST
(
WhereRange
,
MayToOne
)
{
int
src
[]
=
{
0
,
1
,
2
};
int
ans
[]
=
{
1
};
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
where
([](
int
a
){
return
a
==
1
;});
...
...
@@ -104,21 +104,21 @@ TEST(WhereRange, OneToOne)
TEST
(
WhereRange
,
ManyToZero
)
{
int
src
[]
=
{
0
,
1
,
2
};
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
where
([](
int
a
){
return
a
==
5
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
WhereRange
,
OneToZero
)
{
int
src
[]
=
{
5
};
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
where
(
[](
int
a
){
return
a
>
10
;});
EXPECT_THROW
(
dst
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
TEST
(
WhereRange
,
ZeroToZero
)
...
...
@@ -128,5 +128,5 @@ TEST(WhereRange, ZeroToZero)
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
where
(
[](
int
a
){
return
a
>
0
;});
EXPECT_THROW
(
rng
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment