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
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
251 additions
and
192 deletions
+251
-192
README.md
README.md
+17
-13
boolinq.h
include/boolinq/boolinq.h
+96
-41
boolinq_old.h
include/boolinq/boolinq_old.h
+38
-38
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
+22
-22
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
+4
-4
No files found.
README.md
View file @
89aabe3b
...
@@ -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
();
.
to
Std
Vector
();
// 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
();
.
to
Std
Vector
();
// 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
<
T
>
()
-
cast
<
T
>
()
-
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
<
T
>
()
#### Coming soon:
-
groupBy(lambda)
#### Custom:
#### Custom:
...
@@ -138,10 +146,6 @@ int DenisUniqueContactCount =
...
@@ -138,10 +146,6 @@ int DenisUniqueContactCount =
-
unbits
<
T,BitOrder
>
()
-
unbits
<
T,BitOrder
>
()
-
unbits
<
T,BitOrder,ByteOrder
>
()
-
unbits
<
T,BitOrder,ByteOrder
>
()
#### Coming soon:
-
selectMany(lambda)
#### May be will be:
#### May be will be:
-
gz()
-
gz()
...
...
include/boolinq/boolinq.h
View file @
89aabe3b
...
@@ -5,7 +5,9 @@
...
@@ -5,7 +5,9 @@
#include <iterator>
#include <iterator>
#include <iostream>
#include <iostream>
#include <vector>
#include <vector>
#include <deque>
#include <list>
#include <list>
#include <set>
#include <unordered_set>
#include <unordered_set>
//
//
...
@@ -64,7 +66,7 @@ namespace boolinq {
...
@@ -64,7 +66,7 @@ namespace boolinq {
void
foreach
(
std
::
function
<
void
(
T
)
>
apply
)
const
void
foreach
(
std
::
function
<
void
(
T
)
>
apply
)
const
{
{
return
foreach_i
([
apply
](
T
&&
value
,
int
index
)
{
return
apply
(
value
);
});
return
foreach_i
([
apply
](
T
value
,
int
index
)
{
return
apply
(
value
);
});
}
}
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
where_i
(
std
::
function
<
bool
(
T
,
int
)
>
filter
)
const
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
where_i
(
std
::
function
<
bool
(
T
,
int
)
>
filter
)
const
...
@@ -84,7 +86,7 @@ namespace boolinq {
...
@@ -84,7 +86,7 @@ namespace boolinq {
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
where
(
std
::
function
<
bool
(
T
)
>
filter
)
const
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
where
(
std
::
function
<
bool
(
T
)
>
filter
)
const
{
{
return
where_i
([
filter
](
T
&&
value
,
int
index
)
{
return
filter
(
value
);
});
return
where_i
([
filter
](
T
value
,
int
index
)
{
return
filter
(
value
);
});
}
}
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
take
(
int
count
)
const
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
take
(
int
count
)
const
...
@@ -99,7 +101,7 @@ namespace boolinq {
...
@@ -99,7 +101,7 @@ namespace boolinq {
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
takeWhile_i
(
std
::
function
<
bool
(
T
,
int
)
>
predicate
)
const
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
takeWhile_i
(
std
::
function
<
bool
(
T
,
int
)
>
predicate
)
const
{
{
return
where_i
([
predicate
](
T
&&
value
,
int
i
)
{
return
where_i
([
predicate
](
T
value
,
int
i
)
{
if
(
!
predicate
(
value
,
i
))
{
if
(
!
predicate
(
value
,
i
))
{
throw
LinqEndException
();
throw
LinqEndException
();
}
}
...
@@ -109,16 +111,18 @@ namespace boolinq {
...
@@ -109,16 +111,18 @@ namespace boolinq {
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
takeWhile
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
takeWhile
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
{
{
return
takeWhile_i
([
predicate
](
T
&&
value
,
int
/*i*/
)
{
return
predicate
(
value
);
});
return
takeWhile_i
([
predicate
](
T
value
,
int
/*i*/
)
{
return
predicate
(
value
);
});
}
}
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
skip
(
int
count
)
const
Linq
<
LinqIndex
<
S
,
T
>
,
T
>
skip
(
int
count
)
const
{
{
return
where_i
([
count
](
T
&&
value
,
int
i
)
{
return
i
>=
count
;
});
return
where_i
([
count
](
T
value
,
int
i
)
{
return
i
>=
count
;
});
}
}
template
<
typename
SS
,
typename
TT
>
template
<
typename
SS
,
typename
TT
>
struct
LinqIndexFlag
:
public
LinqIndex
<
SS
,
TT
>
{
struct
LinqIndexFlag
{
Linq
<
SS
,
TT
>
linq
;
int
index
;
bool
flag
;
bool
flag
;
};
};
...
@@ -142,7 +146,7 @@ namespace boolinq {
...
@@ -142,7 +146,7 @@ namespace boolinq {
Linq
<
LinqIndexFlag
<
S
,
T
>
,
T
>
skipWhile
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
Linq
<
LinqIndexFlag
<
S
,
T
>
,
T
>
skipWhile
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
{
{
return
skipWhile_i
([
predicate
](
T
&&
value
,
int
/*i*/
)
{
return
predicate
(
value
);
});
return
skipWhile_i
([
predicate
](
T
value
,
int
/*i*/
)
{
return
predicate
(
value
);
});
}
}
template
<
typename
F
,
typename
_TRet
=
typename
std
::
result_of
<
F
(
T
,
int
)
>::
type
>
template
<
typename
F
,
typename
_TRet
=
typename
std
::
result_of
<
F
(
T
,
int
)
>::
type
>
...
@@ -159,13 +163,37 @@ namespace boolinq {
...
@@ -159,13 +163,37 @@ namespace boolinq {
template
<
typename
F
,
typename
_TRet
=
typename
std
::
result_of
<
F
(
T
)
>::
type
>
template
<
typename
F
,
typename
_TRet
=
typename
std
::
result_of
<
F
(
T
)
>::
type
>
auto
select
(
F
apply
)
const
->
Linq
<
LinqIndex
<
S
,
T
>
,
_TRet
>
auto
select
(
F
apply
)
const
->
Linq
<
LinqIndex
<
S
,
T
>
,
_TRet
>
{
{
return
select_i
([
apply
](
T
&&
value
,
int
index
)
{
return
apply
(
value
);
});
return
select_i
([
apply
](
T
value
,
int
/*index*/
)
{
return
apply
(
value
);
});
}
}
template
<
typename
TRet
>
template
<
typename
TRet
>
Linq
<
LinqIndex
<
S
,
T
>
,
TRet
>
cast
()
const
Linq
<
LinqIndex
<
S
,
T
>
,
TRet
>
cast
()
const
{
{
return
select
([](
T
&&
value
)
{
return
TRet
(
value
);
});
return
select_i
([](
T
value
,
int
/*i*/
)
{
return
TRet
(
value
);
});
}
template
<
typename
S1
,
typename
T1
,
typename
S2
,
typename
T2
>
struct
LinqLinq
{
Linq
<
S1
,
T1
>
first
;
Linq
<
S2
,
T2
>
second
;
bool
flag
;
};
template
<
typename
S2
,
typename
T2
>
Linq
<
LinqLinq
<
S
,
T
,
S2
,
T2
>
,
T
>
concat
(
const
Linq
<
S2
,
T2
>
&
rhs
)
const
{
return
Linq
<
LinqLinq
<
S
,
T
,
S2
,
T2
>
,
T
>
(
{
*
this
,
rhs
,
false
},
[](
auto
&
tuple
){
if
(
!
tuple
.
flag
)
{
try
{
return
tuple
.
first
.
next
();
}
catch
(
LinqEndException
&
)
{}
}
return
tuple
.
second
.
next
();
}
);
}
}
template
<
typename
SS
,
typename
TT
,
typename
TCurrent
>
template
<
typename
SS
,
typename
TT
,
typename
TCurrent
>
...
@@ -203,7 +231,7 @@ namespace boolinq {
...
@@ -203,7 +231,7 @@ namespace boolinq {
auto
selectMany
(
F
apply
)
const
auto
selectMany
(
F
apply
)
const
->
Linq
<
LinqCurrentIndexFinished
<
S
,
T
,
_TRet
>
,
typename
_TRet
::
value_type
>
->
Linq
<
LinqCurrentIndexFinished
<
S
,
T
,
_TRet
>
,
typename
_TRet
::
value_type
>
{
{
return
selectMany_i
([
apply
](
T
&&
value
,
int
index
)
{
return
apply
(
value
);
});
return
selectMany_i
([
apply
](
T
value
,
int
index
)
{
return
apply
(
value
);
});
}
}
template
<
typename
SS
,
typename
TT
,
typename
TTRet2
>
template
<
typename
SS
,
typename
TT
,
typename
TTRet2
>
...
@@ -212,11 +240,11 @@ namespace boolinq {
...
@@ -212,11 +240,11 @@ namespace boolinq {
std
::
unordered_set
<
TTRet2
>
set
;
std
::
unordered_set
<
TTRet2
>
set
;
};
};
template
<
typename
TRet
>
template
<
typename
F
,
typename
_TRet
=
typename
std
::
result_of
<
F
(
T
)
>::
type
>
Linq
<
LinqUnorderedSet
<
S
,
T
,
TRet
>
,
T
>
distinct
(
std
::
function
<
TRet
(
T
)
>
transform
)
const
auto
distinct
(
F
transform
)
const
->
Linq
<
LinqUnorderedSet
<
S
,
T
,
_TRet
>
,
T
>
{
{
return
Linq
<
LinqUnorderedSet
<
S
,
T
,
TRet
>
,
T
>
(
return
Linq
<
LinqUnorderedSet
<
S
,
T
,
_
TRet
>
,
T
>
(
{
*
this
,
std
::
unordered_set
<
TRet
>
()},
{
*
this
,
std
::
unordered_set
<
_
TRet
>
()},
[
transform
](
auto
&
tuple
)
{
[
transform
](
auto
&
tuple
)
{
while
(
true
)
{
while
(
true
)
{
T
value
=
tuple
.
linq
.
next
();
T
value
=
tuple
.
linq
.
next
();
...
@@ -230,7 +258,7 @@ namespace boolinq {
...
@@ -230,7 +258,7 @@ namespace boolinq {
Linq
<
LinqUnorderedSet
<
S
,
T
,
T
>
,
T
>
distinct
()
const
Linq
<
LinqUnorderedSet
<
S
,
T
,
T
>
,
T
>
distinct
()
const
{
{
return
distinct
([](
T
&&
value
)
{
return
value
;
});
return
distinct
([](
T
value
)
{
return
value
;
});
}
}
template
<
typename
TT
>
template
<
typename
TT
>
...
@@ -265,7 +293,7 @@ namespace boolinq {
...
@@ -265,7 +293,7 @@ namespace boolinq {
Linq
<
StdVectorAndIterator
<
T
>
,
T
>
orderBy
()
const
Linq
<
StdVectorAndIterator
<
T
>
,
T
>
orderBy
()
const
{
{
return
orderBy
([](
T
&&
value
)
{
return
value
;
});
return
orderBy
([](
T
value
)
{
return
value
;
});
}
}
template
<
typename
TT
>
template
<
typename
TT
>
...
@@ -310,9 +338,9 @@ namespace boolinq {
...
@@ -310,9 +338,9 @@ namespace boolinq {
}
}
template
<
typename
F
>
template
<
typename
F
>
auto
sum
(
F
transform
)
const
->
typename
std
::
result_of
<
F
(
T
,
T
)
>::
type
auto
sum
(
F
transform
)
const
->
typename
std
::
result_of
<
F
(
T
)
>::
type
{
{
return
aggregate
<
T
>
(
T
(),
[
transform
](
T
accumulator
,
T
&&
value
)
{
return
aggregate
<
T
>
(
T
(),
[
transform
](
T
accumulator
,
T
value
)
{
return
accumulator
+
transform
(
value
);
return
accumulator
+
transform
(
value
);
});
});
}
}
...
@@ -327,7 +355,7 @@ namespace boolinq {
...
@@ -327,7 +355,7 @@ namespace boolinq {
auto
avg
(
F
transform
)
const
->
typename
std
::
result_of
<
F
(
T
)
>::
type
auto
avg
(
F
transform
)
const
->
typename
std
::
result_of
<
F
(
T
)
>::
type
{
{
int
count
=
0
;
int
count
=
0
;
T
res
=
sum
([
transform
,
&
count
](
T
&&
value
)
{
T
res
=
sum
([
transform
,
&
count
](
T
value
)
{
count
++
;
count
++
;
return
transform
(
value
);
return
transform
(
value
);
});
});
...
@@ -343,7 +371,7 @@ namespace boolinq {
...
@@ -343,7 +371,7 @@ namespace boolinq {
int
count
()
const
int
count
()
const
{
{
int
index
=
0
;
int
index
=
0
;
foreach
([
&
index
](
T
&&
/**/
a
)
{
index
++
;
});
foreach
([
&
index
](
T
/**/
a
)
{
index
++
;
});
return
index
;
return
index
;
}
}
...
@@ -354,7 +382,7 @@ namespace boolinq {
...
@@ -354,7 +382,7 @@ namespace boolinq {
int
count
(
const
T
&
item
)
const
int
count
(
const
T
&
item
)
const
{
{
return
count
([
item
](
T
&&
value
)
{
return
item
==
value
;
});
return
count
([
item
](
T
value
)
{
return
item
==
value
;
});
}
}
// Bool aggregators
// Bool aggregators
...
@@ -364,7 +392,7 @@ namespace boolinq {
...
@@ -364,7 +392,7 @@ namespace boolinq {
Linq
<
S
,
T
>
linq
=
*
this
;
Linq
<
S
,
T
>
linq
=
*
this
;
try
{
try
{
while
(
true
)
{
while
(
true
)
{
if
(
predicate
(
linq
.
next
Object
()))
if
(
predicate
(
linq
.
next
()))
return
true
;
return
true
;
}
}
}
}
...
@@ -374,22 +402,22 @@ namespace boolinq {
...
@@ -374,22 +402,22 @@ namespace boolinq {
bool
any
()
const
bool
any
()
const
{
{
return
any
([](
T
&&
value
)
{
return
static_cast
<
bool
>
(
value
);
});
return
any
([](
T
value
)
{
return
static_cast
<
bool
>
(
value
);
});
}
}
bool
all
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
bool
all
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
{
{
return
!
any
([
predicate
](
T
&&
value
)
{
return
!
predicate
(
value
);
});
return
!
any
([
predicate
](
T
value
)
{
return
!
predicate
(
value
);
});
}
}
bool
all
()
const
bool
all
()
const
{
{
return
all
([](
T
&&
value
)
{
return
static_cast
<
bool
>
(
value
);
});
return
all
([](
T
value
)
{
return
static_cast
<
bool
>
(
value
);
});
}
}
bool
contains
(
const
T
&
item
)
const
bool
contains
(
const
T
&
item
)
const
{
{
return
any
([
&
item
](
T
&&
value
)
{
return
value
==
item
;
});
return
any
([
&
item
](
T
value
)
{
return
value
==
item
;
});
}
}
// Election aggregators
// Election aggregators
...
@@ -418,7 +446,7 @@ namespace boolinq {
...
@@ -418,7 +446,7 @@ namespace boolinq {
T
max
()
const
T
max
()
const
{
{
return
max
([](
T
&&
value
)
{
return
value
;
});
return
max
([](
T
value
)
{
return
value
;
});
}
}
template
<
typename
F
>
template
<
typename
F
>
...
@@ -431,7 +459,7 @@ namespace boolinq {
...
@@ -431,7 +459,7 @@ namespace boolinq {
T
min
()
const
T
min
()
const
{
{
return
min
([](
T
&&
value
)
{
return
value
;
});
return
min
([](
T
value
)
{
return
value
;
});
}
}
// Single object returners
// Single object returners
...
@@ -462,13 +490,13 @@ namespace boolinq {
...
@@ -462,13 +490,13 @@ namespace boolinq {
T
firstOrDefault
()
const
T
firstOrDefault
()
const
{
{
firstOrDefault
([](
T
&&
/*value*/
)
{
return
true
;
});
firstOrDefault
([](
T
/*value*/
)
{
return
true
;
});
}
}
T
last
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
T
last
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
{
{
T
res
;
T
res
;
foreach
([
&
res
](
T
&&
value
)
{
foreach
([
&
res
](
T
value
)
{
res
=
value
;
res
=
value
;
});
});
return
res
;
return
res
;
...
@@ -476,7 +504,7 @@ namespace boolinq {
...
@@ -476,7 +504,7 @@ namespace boolinq {
T
last
()
const
T
last
()
const
{
{
return
last
([](
T
&&
/*value*/
)
{
return
true
;
});
return
last
([](
T
/*value*/
)
{
return
true
;
});
}
}
T
lastOrDefault
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
T
lastOrDefault
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
...
@@ -490,7 +518,7 @@ namespace boolinq {
...
@@ -490,7 +518,7 @@ namespace boolinq {
T
lastOrDefault
()
const
T
lastOrDefault
()
const
{
{
return
lastOrDefault
([](
T
&&
/*value*/
)
{
return
true
;
});
return
lastOrDefault
([](
T
/*value*/
)
{
return
true
;
});
}
}
// Export to containers
// Export to containers
...
@@ -498,7 +526,7 @@ namespace boolinq {
...
@@ -498,7 +526,7 @@ namespace boolinq {
std
::
vector
<
T
>
toStdVector
()
const
std
::
vector
<
T
>
toStdVector
()
const
{
{
std
::
vector
<
T
>
items
;
std
::
vector
<
T
>
items
;
foreach
([
&
items
](
T
&&
value
)
{
foreach
([
&
items
](
T
value
)
{
items
.
push_back
(
value
);
items
.
push_back
(
value
);
});
});
return
items
;
return
items
;
...
@@ -507,12 +535,39 @@ namespace boolinq {
...
@@ -507,12 +535,39 @@ namespace boolinq {
std
::
list
<
T
>
toStdList
()
const
std
::
list
<
T
>
toStdList
()
const
{
{
std
::
list
<
T
>
items
;
std
::
list
<
T
>
items
;
foreach
([
&
items
](
T
&&
value
)
{
foreach
([
&
items
](
T
value
)
{
items
.
push_back
(
value
);
items
.
push_back
(
value
);
});
});
return
items
;
return
items
;
}
}
std
::
deque
<
T
>
toStdDeque
()
const
{
std
::
deque
<
T
>
items
;
foreach
([
&
items
](
T
value
)
{
items
.
push_back
(
value
);
});
return
items
;
}
std
::
set
<
T
>
toStdSet
()
const
{
std
::
set
<
T
>
items
;
foreach
([
&
items
](
T
value
)
{
items
.
insert
(
value
);
});
return
items
;
}
std
::
unordered_set
<
T
>
toStdUnorderedSet
()
const
{
std
::
unordered_set
<
T
>
items
;
foreach
([
&
items
](
T
value
)
{
items
.
insert
(
value
);
});
return
items
;
}
// Bits and bytes
// Bits and bytes
template
<
typename
SS
,
typename
TT
>
template
<
typename
SS
,
typename
TT
>
...
@@ -550,7 +605,7 @@ namespace boolinq {
...
@@ -550,7 +605,7 @@ namespace boolinq {
template
<
typename
TRet
>
template
<
typename
TRet
>
Linq
<
LinqBytesBitsValueIndex
<
S
,
T
>
,
TRet
>
unbytes
(
BytesDirection
direction
=
BytesFirstToLast
)
const
Linq
<
LinqBytesBitsValueIndex
<
S
,
T
>
,
TRet
>
unbytes
(
BytesDirection
direction
=
BytesFirstToLast
)
const
{
{
return
Linq
<
LinqBytesBitsValueIndex
<
S
,
T
>
,
in
t
>
(
return
Linq
<
LinqBytesBitsValueIndex
<
S
,
T
>
,
TRe
t
>
(
{
*
this
,
direction
,
BitsHighToLow
,
T
(),
0
},
{
*
this
,
direction
,
BitsHighToLow
,
T
(),
0
},
[](
auto
&
tuple
)
{
[](
auto
&
tuple
)
{
TRet
value
;
TRet
value
;
...
@@ -598,10 +653,10 @@ namespace boolinq {
...
@@ -598,10 +653,10 @@ namespace boolinq {
);
);
}
}
template
<
typename
TRet
>
template
<
typename
TRet
=
uint8_t
>
Linq
<
LinqBytesBitsValueIndex
<
S
,
T
>
,
TRet
>
unbits
(
BitsDirection
bitsDir
=
BitsHighToLow
,
BytesDirection
bytesDir
=
BytesFirstToLast
)
const
Linq
<
LinqBytesBitsValueIndex
<
S
,
T
>
,
TRet
>
unbits
(
BitsDirection
bitsDir
=
BitsHighToLow
,
BytesDirection
bytesDir
=
BytesFirstToLast
)
const
{
{
return
Linq
<
LinqBytesBitsValueIndex
<
S
,
T
>
,
in
t
>
(
return
Linq
<
LinqBytesBitsValueIndex
<
S
,
T
>
,
TRe
t
>
(
{
*
this
,
bytesDir
,
bitsDir
,
T
(),
0
},
{
*
this
,
bytesDir
,
bitsDir
,
T
(),
0
},
[](
auto
&
tuple
)
{
[](
auto
&
tuple
)
{
TRet
value
;
TRet
value
;
...
@@ -649,16 +704,16 @@ namespace boolinq {
...
@@ -649,16 +704,16 @@ namespace boolinq {
return
Linq
<
std
::
pair
<
T
,
T
>
,
typename
std
::
iterator_traits
<
T
>::
value_type
>
(
return
Linq
<
std
::
pair
<
T
,
T
>
,
typename
std
::
iterator_traits
<
T
>::
value_type
>
(
{
begin
,
end
},
{
begin
,
end
},
[](
auto
&
pair
)
{
[](
auto
&
pair
)
{
if
(
pair
.
first
<
pair
.
second
)
{
if
(
pair
.
first
==
pair
.
second
)
{
return
*
(
pair
.
first
++
);
}
throw
LinqEndException
();
throw
LinqEndException
();
}
}
return
*
(
pair
.
first
++
);
}
);
);
}
}
template
<
typename
T
>
template
<
typename
T
>
Linq
<
std
::
pair
<
T
,
T
>
,
T
>
from
(
T
it
,
int
n
)
Linq
<
std
::
pair
<
T
,
T
>
,
typename
std
::
iterator_traits
<
T
>::
value_type
>
from
(
T
it
,
int
n
)
{
{
return
from
(
it
,
it
+
n
);
return
from
(
it
,
it
+
n
);
}
}
...
...
include/boolinq/boolinq_old.h
View file @
89aabe3b
...
@@ -36,13 +36,13 @@ namespace boolinq
...
@@ -36,13 +36,13 @@ namespace boolinq
public
:
public
:
typedef
T
value_type
;
typedef
T
value_type
;
Enumerator
(
std
::
function
<
T
(
S
&
)
>
next
Object
,
S
data
)
Enumerator
(
std
::
function
<
T
(
S
&
)
>
next
,
S
data
)
:
_nextObject
(
next
Object
)
:
_nextObject
(
next
)
,
_data
(
data
)
,
_data
(
data
)
{
{
}
}
T
next
Object
()
T
next
()
{
{
return
_nextObject
(
_data
);
return
_nextObject
(
_data
);
}
}
...
@@ -57,7 +57,7 @@ namespace boolinq
...
@@ -57,7 +57,7 @@ namespace boolinq
if
(
i
>
0
)
{
if
(
i
>
0
)
{
stream
<<
' '
;
stream
<<
' '
;
}
}
stream
<<
enumerator
.
next
Object
();
stream
<<
enumerator
.
next
();
}
}
}
}
catch
(
LinqEndException
&
)
{}
catch
(
LinqEndException
&
)
{}
...
@@ -133,9 +133,9 @@ namespace boolinq
...
@@ -133,9 +133,9 @@ namespace boolinq
{
{
}
}
T
next
Object
()
T
next
()
{
{
return
_enumerator
.
next
Object
();
return
_enumerator
.
next
();
}
}
// Main methods
// Main methods
...
@@ -147,7 +147,7 @@ namespace boolinq
...
@@ -147,7 +147,7 @@ namespace boolinq
try
try
{
{
for
(;;)
for
(;;)
action
(
en
.
next
Object
(),
index
++
);
action
(
en
.
next
(),
index
++
);
}
}
catch
(
LinqEndException
&
)
{}
catch
(
LinqEndException
&
)
{}
}
}
...
@@ -162,7 +162,7 @@ namespace boolinq
...
@@ -162,7 +162,7 @@ namespace boolinq
return
Enumerator
<
T
,
std
::
pair
<
TE
,
int
>
>
([
=
](
std
::
pair
<
TE
,
int
>
&
pair
)
->
T
{
return
Enumerator
<
T
,
std
::
pair
<
TE
,
int
>
>
([
=
](
std
::
pair
<
TE
,
int
>
&
pair
)
->
T
{
T
object
;
T
object
;
do
do
object
=
pair
.
first
.
next
Object
();
object
=
pair
.
first
.
next
();
while
(
!
predicate
(
object
,
pair
.
second
++
));
while
(
!
predicate
(
object
,
pair
.
second
++
));
return
object
;
return
object
;
},
std
::
make_pair
(
_enumerator
,
0
));
},
std
::
make_pair
(
_enumerator
,
0
));
...
@@ -186,7 +186,7 @@ namespace boolinq
...
@@ -186,7 +186,7 @@ namespace boolinq
LinqObj
<
Enumerator
<
T
,
std
::
pair
<
TE
,
int
>
>
>
takeWhile_i
(
std
::
function
<
bool
(
T
,
int
)
>
predicate
)
const
LinqObj
<
Enumerator
<
T
,
std
::
pair
<
TE
,
int
>
>
>
takeWhile_i
(
std
::
function
<
bool
(
T
,
int
)
>
predicate
)
const
{
{
return
Enumerator
<
T
,
std
::
pair
<
TE
,
int
>
>
([
=
](
std
::
pair
<
TE
,
int
>
&
pair
)
->
T
{
return
Enumerator
<
T
,
std
::
pair
<
TE
,
int
>
>
([
=
](
std
::
pair
<
TE
,
int
>
&
pair
)
->
T
{
T
object
=
pair
.
first
.
next
Object
();
T
object
=
pair
.
first
.
next
();
if
(
!
predicate
(
object
,
pair
.
second
++
))
{
if
(
!
predicate
(
object
,
pair
.
second
++
))
{
throw
LinqEndException
();
throw
LinqEndException
();
}
}
...
@@ -208,12 +208,12 @@ namespace boolinq
...
@@ -208,12 +208,12 @@ namespace boolinq
{
{
return
Enumerator
<
T
,
std
::
pair
<
TE
,
int
>
>
([
=
](
std
::
pair
<
TE
,
int
>
&
pair
)
->
T
{
return
Enumerator
<
T
,
std
::
pair
<
TE
,
int
>
>
([
=
](
std
::
pair
<
TE
,
int
>
&
pair
)
->
T
{
if
(
pair
.
second
!=
0
)
{
if
(
pair
.
second
!=
0
)
{
return
pair
.
first
.
next
Object
();
return
pair
.
first
.
next
();
}
}
T
object
;
T
object
;
do
{
do
{
object
=
pair
.
first
.
next
Object
();
object
=
pair
.
first
.
next
();
}
while
(
predicate
(
object
,
pair
.
second
++
));
}
while
(
predicate
(
object
,
pair
.
second
++
));
return
object
;
return
object
;
...
@@ -229,7 +229,7 @@ namespace boolinq
...
@@ -229,7 +229,7 @@ namespace boolinq
LinqObj
<
Enumerator
<
TRet
,
std
::
pair
<
TE
,
int
>
>
>
select_i
(
std
::
function
<
TRet
(
T
,
int
)
>
transform
)
const
LinqObj
<
Enumerator
<
TRet
,
std
::
pair
<
TE
,
int
>
>
>
select_i
(
std
::
function
<
TRet
(
T
,
int
)
>
transform
)
const
{
{
return
Enumerator
<
TRet
,
std
::
pair
<
TE
,
int
>
>
([
=
](
std
::
pair
<
TE
,
int
>
&
pair
)
->
TRet
{
return
Enumerator
<
TRet
,
std
::
pair
<
TE
,
int
>
>
([
=
](
std
::
pair
<
TE
,
int
>
&
pair
)
->
TRet
{
return
transform
(
pair
.
first
.
next
Object
(),
pair
.
second
++
);
return
transform
(
pair
.
first
.
next
(),
pair
.
second
++
);
},
std
::
make_pair
(
_enumerator
,
0
));
},
std
::
make_pair
(
_enumerator
,
0
));
}
}
...
@@ -264,7 +264,7 @@ namespace boolinq
...
@@ -264,7 +264,7 @@ namespace boolinq
return
Enumerator
<
T
,
DataType
>
([
=
](
DataType
&
pair
)
->
T
{
return
Enumerator
<
T
,
DataType
>
([
=
](
DataType
&
pair
)
->
T
{
for
(;;)
{
for
(;;)
{
T
object
=
pair
.
first
.
next
Object
();
T
object
=
pair
.
first
.
next
();
TRet
key
=
transform
(
object
);
TRet
key
=
transform
(
object
);
if
(
pair
.
second
.
find
(
key
)
==
pair
.
second
.
end
())
{
if
(
pair
.
second
.
find
(
key
)
==
pair
.
second
.
end
())
{
pair
.
second
.
insert
(
key
);
pair
.
second
.
insert
(
key
);
...
@@ -316,7 +316,7 @@ namespace boolinq
...
@@ -316,7 +316,7 @@ namespace boolinq
{
{
auto
en
=
_enumerator
;
auto
en
=
_enumerator
;
for
(;;)
{
for
(;;)
{
objects
.
insert
(
en
.
next
Object
());
objects
.
insert
(
en
.
next
());
}
}
}
}
catch
(
LinqEndException
&
)
{}
catch
(
LinqEndException
&
)
{}
...
@@ -351,7 +351,7 @@ namespace boolinq
...
@@ -351,7 +351,7 @@ namespace boolinq
{
{
return
(
pair
.
first
==
pair
.
second
.
crend
())
return
(
pair
.
first
==
pair
.
second
.
crend
())
?
throw
LinqEndException
()
:
*
(
pair
.
first
++
);
?
throw
LinqEndException
()
:
*
(
pair
.
first
++
);
},
DataType
(
toVector
(),
[](
const
std
::
vector
<
T
>
&
vec
){
return
vec
.
crbegin
();}));
},
DataType
(
to
Std
Vector
(),
[](
const
std
::
vector
<
T
>
&
vec
){
return
vec
.
crbegin
();}));
}
}
// Aggregators
// Aggregators
...
@@ -363,7 +363,7 @@ namespace boolinq
...
@@ -363,7 +363,7 @@ namespace boolinq
{
{
auto
en
=
_enumerator
;
auto
en
=
_enumerator
;
for
(;;)
for
(;;)
start
=
accumulate
(
start
,
en
.
next
Object
());
start
=
accumulate
(
start
,
en
.
next
());
}
}
catch
(
LinqEndException
&
)
{}
catch
(
LinqEndException
&
)
{}
return
start
;
return
start
;
...
@@ -444,7 +444,7 @@ namespace boolinq
...
@@ -444,7 +444,7 @@ namespace boolinq
{
{
auto
en
=
_enumerator
;
auto
en
=
_enumerator
;
for
(;;)
for
(;;)
if
(
predicate
(
en
.
next
Object
()))
if
(
predicate
(
en
.
next
()))
return
true
;
return
true
;
}
}
catch
(
LinqEndException
&
)
{}
catch
(
LinqEndException
&
)
{}
...
@@ -476,11 +476,11 @@ namespace boolinq
...
@@ -476,11 +476,11 @@ namespace boolinq
T
elect
(
std
::
function
<
T
(
T
,
T
)
>
accumulate
)
const
T
elect
(
std
::
function
<
T
(
T
,
T
)
>
accumulate
)
const
{
{
auto
en
=
_enumerator
;
auto
en
=
_enumerator
;
T
result
=
en
.
next
Object
();
T
result
=
en
.
next
();
try
try
{
{
for
(;;)
for
(;;)
result
=
accumulate
(
result
,
en
.
next
Object
());
result
=
accumulate
(
result
,
en
.
next
());
}
}
catch
(
LinqEndException
&
)
{}
catch
(
LinqEndException
&
)
{}
return
result
;
return
result
;
...
@@ -526,13 +526,13 @@ namespace boolinq
...
@@ -526,13 +526,13 @@ namespace boolinq
{
{
auto
en
=
_enumerator
;
auto
en
=
_enumerator
;
for
(
int
i
=
0
;
i
<
index
;
i
++
)
for
(
int
i
=
0
;
i
<
index
;
i
++
)
en
.
next
Object
();
en
.
next
();
return
en
.
next
Object
();
return
en
.
next
();
}
}
T
first
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
T
first
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
{
{
return
where
(
predicate
).
_enumerator
.
next
Object
();
return
where
(
predicate
).
_enumerator
.
next
();
}
}
T
first
()
const
T
first
()
const
...
@@ -555,8 +555,8 @@ namespace boolinq
...
@@ -555,8 +555,8 @@ namespace boolinq
T
last
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
T
last
(
std
::
function
<
bool
(
T
)
>
predicate
)
const
{
{
auto
linq
=
where
(
predicate
);
auto
linq
=
where
(
predicate
);
T
object
=
linq
.
_enumerator
.
next
Object
();
T
object
=
linq
.
_enumerator
.
next
();
try
{
for
(;;)
object
=
linq
.
_enumerator
.
next
Object
();
}
try
{
for
(;;)
object
=
linq
.
_enumerator
.
next
();
}
catch
(
LinqEndException
&
)
{
return
object
;
}
catch
(
LinqEndException
&
)
{
return
object
;
}
}
}
...
@@ -585,12 +585,12 @@ namespace boolinq
...
@@ -585,12 +585,12 @@ namespace boolinq
return
Enumerator
<
T
,
DataType
>
([
=
](
DataType
&
pair
)
->
T
{
return
Enumerator
<
T
,
DataType
>
([
=
](
DataType
&
pair
)
->
T
{
if
(
pair
.
first
)
if
(
pair
.
first
)
return
pair
.
second
.
second
.
next
Object
();
return
pair
.
second
.
second
.
next
();
try
{
return
pair
.
second
.
first
.
next
Object
();
}
try
{
return
pair
.
second
.
first
.
next
();
}
catch
(
LinqEndException
&
)
catch
(
LinqEndException
&
)
{
{
pair
.
first
=
true
;
pair
.
first
=
true
;
return
pair
.
second
.
second
.
next
Object
();
return
pair
.
second
.
second
.
next
();
}
}
},
std
::
make_pair
(
false
,
std
::
make_pair
(
_enumerator
,
rhs
.
_enumerator
)));
},
std
::
make_pair
(
false
,
std
::
make_pair
(
_enumerator
,
rhs
.
_enumerator
)));
}
}
...
@@ -606,7 +606,7 @@ namespace boolinq
...
@@ -606,7 +606,7 @@ namespace boolinq
{
{
auto
en
=
_enumerator
;
auto
en
=
_enumerator
;
for
(;;)
for
(;;)
func
(
container
,
en
.
next
Object
());
func
(
container
,
en
.
next
());
}
}
catch
(
LinqEndException
&
)
{}
catch
(
LinqEndException
&
)
{}
return
container
;
return
container
;
...
@@ -614,28 +614,28 @@ namespace boolinq
...
@@ -614,28 +614,28 @@ namespace boolinq
public
:
public
:
std
::
vector
<
T
>
toVector
()
const
std
::
vector
<
T
>
to
Std
Vector
()
const
{
{
return
exportToContainer
<
std
::
vector
<
T
>
>
([](
std
::
vector
<
T
>
&
container
,
const
T
&
value
){
return
exportToContainer
<
std
::
vector
<
T
>
>
([](
std
::
vector
<
T
>
&
container
,
const
T
&
value
){
container
.
push_back
(
value
);
container
.
push_back
(
value
);
});
});
}
}
std
::
list
<
T
>
toList
()
const
std
::
list
<
T
>
to
Std
List
()
const
{
{
return
exportToContainer
<
std
::
list
<
T
>
>
([](
std
::
list
<
T
>
&
container
,
const
T
&
value
){
return
exportToContainer
<
std
::
list
<
T
>
>
([](
std
::
list
<
T
>
&
container
,
const
T
&
value
){
container
.
push_back
(
value
);
container
.
push_back
(
value
);
});
});
}
}
std
::
deque
<
T
>
toDeque
()
const
std
::
deque
<
T
>
to
Std
Deque
()
const
{
{
return
exportToContainer
<
std
::
deque
<
T
>
>
([](
std
::
deque
<
T
>
&
container
,
const
T
&
value
){
return
exportToContainer
<
std
::
deque
<
T
>
>
([](
std
::
deque
<
T
>
&
container
,
const
T
&
value
){
container
.
push_back
(
value
);
container
.
push_back
(
value
);
});
});
}
}
std
::
set
<
T
>
toSet
()
const
std
::
set
<
T
>
toS
tdS
et
()
const
{
{
return
exportToContainer
<
std
::
set
<
T
>
>
([](
std
::
set
<
T
>
&
container
,
const
T
&
value
){
return
exportToContainer
<
std
::
set
<
T
>
>
([](
std
::
set
<
T
>
&
container
,
const
T
&
value
){
container
.
insert
(
value
);
container
.
insert
(
value
);
...
@@ -649,14 +649,14 @@ namespace boolinq
...
@@ -649,14 +649,14 @@ namespace boolinq
typedef
std
::
pair
<
int
,
std
::
pair
<
TE
,
T
>
>
DataType
;
typedef
std
::
pair
<
int
,
std
::
pair
<
TE
,
T
>
>
DataType
;
auto
pair
=
std
::
make_pair
(
_enumerator
,
T
());
auto
pair
=
std
::
make_pair
(
_enumerator
,
T
());
pair
.
second
=
pair
.
first
.
next
Object
();
pair
.
second
=
pair
.
first
.
next
();
return
Enumerator
<
int
,
DataType
>
([
=
](
DataType
&
pair_
)
->
int
{
return
Enumerator
<
int
,
DataType
>
([
=
](
DataType
&
pair_
)
->
int
{
if
((
direction
==
BytesFirstToLast
&&
pair_
.
first
==
sizeof
(
T
))
if
((
direction
==
BytesFirstToLast
&&
pair_
.
first
==
sizeof
(
T
))
||
(
direction
==
BytesLastToFirst
&&
pair_
.
first
==
-
1
))
||
(
direction
==
BytesLastToFirst
&&
pair_
.
first
==
-
1
))
{
{
pair_
.
first
=
(
direction
==
BytesFirstToLast
)
?
0
:
sizeof
(
T
)
-
1
;
pair_
.
first
=
(
direction
==
BytesFirstToLast
)
?
0
:
sizeof
(
T
)
-
1
;
pair_
.
second
.
second
=
pair_
.
second
.
first
.
next
Object
();
pair_
.
second
.
second
=
pair_
.
second
.
first
.
next
();
}
}
unsigned
char
*
ptr
=
reinterpret_cast
<
unsigned
char
*>
(
&
pair_
.
second
.
second
);
unsigned
char
*
ptr
=
reinterpret_cast
<
unsigned
char
*>
(
&
pair_
.
second
.
second
);
int
value
=
ptr
[
pair_
.
first
];
int
value
=
ptr
[
pair_
.
first
];
...
@@ -675,7 +675,7 @@ namespace boolinq
...
@@ -675,7 +675,7 @@ namespace boolinq
i
!=
((
direction
==
BytesFirstToLast
)
?
int
(
sizeof
(
TRet
))
:
-
1
);
i
!=
((
direction
==
BytesFirstToLast
)
?
int
(
sizeof
(
TRet
))
:
-
1
);
i
+=
(
direction
==
BytesFirstToLast
)
?
1
:
-
1
)
i
+=
(
direction
==
BytesFirstToLast
)
?
1
:
-
1
)
{
{
ptr
[
i
]
=
en
.
next
Object
();
ptr
[
i
]
=
en
.
next
();
}
}
return
object
;
return
object
;
},
_enumerator
);
},
_enumerator
);
...
@@ -692,13 +692,13 @@ namespace boolinq
...
@@ -692,13 +692,13 @@ namespace boolinq
||
(
direction
==
BitsHighToLow
&&
pair
.
first
==
-
1
))
||
(
direction
==
BitsHighToLow
&&
pair
.
first
==
-
1
))
{
{
pair
.
first
=
(
direction
==
BitsLowToHigh
)
?
0
:
CHAR_BIT
-
1
;
pair
.
first
=
(
direction
==
BitsLowToHigh
)
?
0
:
CHAR_BIT
-
1
;
pair
.
second
.
second
=
static_cast
<
unsigned
char
>
(
pair
.
second
.
first
.
next
Object
());
pair
.
second
.
second
=
static_cast
<
unsigned
char
>
(
pair
.
second
.
first
.
next
());
}
}
int
value
=
1
&
(
pair
.
second
.
second
>>
(
pair
.
first
%
CHAR_BIT
));
int
value
=
1
&
(
pair
.
second
.
second
>>
(
pair
.
first
%
CHAR_BIT
));
pair
.
first
+=
(
direction
==
BitsLowToHigh
)
?
1
:
-
1
;
pair
.
first
+=
(
direction
==
BitsLowToHigh
)
?
1
:
-
1
;
return
value
;
return
value
;
},
std
::
make_pair
((
direction
==
BitsLowToHigh
)
?
0
:
CHAR_BIT
-
1
,
},
std
::
make_pair
((
direction
==
BitsLowToHigh
)
?
0
:
CHAR_BIT
-
1
,
std
::
make_pair
(
inner
,
inner
.
next
Object
())));
std
::
make_pair
(
inner
,
inner
.
next
())));
}
}
LinqObj
<
Enumerator
<
unsigned
char
,
TE
>
>
unbits
(
BitsDirection
direction
=
BitsHighToLow
)
const
LinqObj
<
Enumerator
<
unsigned
char
,
TE
>
>
unbits
(
BitsDirection
direction
=
BitsHighToLow
)
const
...
@@ -709,7 +709,7 @@ namespace boolinq
...
@@ -709,7 +709,7 @@ namespace boolinq
i
!=
((
direction
==
BitsLowToHigh
)
?
CHAR_BIT
:
-
1
);
i
!=
((
direction
==
BitsLowToHigh
)
?
CHAR_BIT
:
-
1
);
i
+=
(
direction
==
BitsLowToHigh
)
?
1
:
-
1
)
i
+=
(
direction
==
BitsLowToHigh
)
?
1
:
-
1
)
{
{
object
|=
(
en
.
next
Object
()
<<
i
);
object
|=
(
en
.
next
()
<<
i
);
}
}
return
object
;
return
object
;
},
_enumerator
);
},
_enumerator
);
...
...
test/CommonTests.h
View file @
89aabe3b
...
@@ -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
.
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
>
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
.
next
Object
());
EXPECT_EQ
(
ans
[
i
],
dst
.
next
());
EXPECT_THROW
(
dst
.
next
Object
(),
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
.
toS
tdS
et
();
EXPECT_EQ
(
expected
.
size
(),
actual
.
size
());
EXPECT_EQ
(
expected
.
size
(),
actual
.
size
());
...
...
test/GroupByRangeTest.cpp
View file @
89aabe3b
...
@@ -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.next
Object
(), 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.next
Object
(), 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.next
Object
(), LinqEndException);
EXPECT_THROW(dst.next(), LinqEndException);
}
}
*/
*/
test/IterRangeTest.cpp
View file @
89aabe3b
...
@@ -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
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
}
test/LinqTest.cpp
View file @
89aabe3b
...
@@ -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
.
next
Object
());
EXPECT_EQ
(
i
,
rng
.
next
());
}
}
EXPECT_THROW
(
rng
.
next
Object
(),
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
.
next
Object
());
EXPECT_EQ
(
i
,
rng
.
next
());
}
}
EXPECT_THROW
(
rng
.
next
Object
(),
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
();
.
to
Std
Vector
();
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
();
.
to
Std
Vector
();
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
();
.
to
Std
Vector
();
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
();
.
to
Std
Vector
();
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
();
.
to
Std
Vector
();
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
();
.
to
Std
Vector
();
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
.
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)
...
@@ -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
.
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)
...
@@ -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,7 +301,7 @@ TEST(Linq, MessagesCountUniqueContacts)
...
@@ -301,7 +301,7 @@ 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
);})
...
...
test/OrderByRangeTest.cpp
View file @
89aabe3b
...
@@ -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
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
...
...
test/SkipRangeTest.cpp
View file @
89aabe3b
...
@@ -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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
test/SkipWhileRangeTest.cpp
View file @
89aabe3b
...
@@ -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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
test/SumTest.cpp
View file @
89aabe3b
...
@@ -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
);
...
...
test/TakeRangeTest.cpp
View file @
89aabe3b
...
@@ -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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
rng
.
next
(),
LinqEndException
);
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
test/TakeWhileRangeTest.cpp
View file @
89aabe3b
...
@@ -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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
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
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
test/ToDequeTest.cpp
View file @
89aabe3b
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
using
namespace
boolinq
;
using
namespace
boolinq
;
TEST
(
To
Deque
,
Deque2Deque
)
TEST
(
toStd
Deque
,
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
.
to
Std
Deque
();
EXPECT_EQ
(
dst
,
src
);
EXPECT_EQ
(
dst
,
src
);
}
}
test/ToListTest.cpp
View file @
89aabe3b
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
using
namespace
boolinq
;
using
namespace
boolinq
;
TEST
(
To
List
,
List2List
)
TEST
(
toStd
List
,
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
.
to
Std
List
();
EXPECT_EQ
(
dst
,
src
);
EXPECT_EQ
(
dst
,
src
);
}
}
test/ToSetTest.cpp
View file @
89aabe3b
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
using
namespace
boolinq
;
using
namespace
boolinq
;
TEST
(
To
Set
,
Vector2Set
)
TEST
(
toStd
Set
,
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
.
toS
tdS
et
();
EXPECT_EQ
(
3U
,
dst
.
size
());
EXPECT_EQ
(
3U
,
dst
.
size
());
EXPECT_NE
(
dst
.
end
(),
dst
.
find
(
1
));
EXPECT_NE
(
dst
.
end
(),
dst
.
find
(
1
));
...
...
test/ToVectorTest.cpp
View file @
89aabe3b
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
using
namespace
boolinq
;
using
namespace
boolinq
;
TEST
(
To
Vector
,
Vector2Vector
)
TEST
(
toStd
Vector
,
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
.
to
Std
Vector
();
EXPECT_EQ
(
dst
,
src
);
EXPECT_EQ
(
dst
,
src
);
}
}
test/UnbytesRangeTest.cpp
View file @
89aabe3b
...
@@ -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
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
}
test/WhereRangeTest.cpp
View file @
89aabe3b
...
@@ -77,7 +77,7 @@ TEST(WhereRange, NameAgeLess)
...
@@ -77,7 +77,7 @@ TEST(WhereRange, NameAgeLess)
CheckRangeEqArray
(
dst
,
ans
,
[](
const
NameAge
&
a
){
return
a
.
name
;});
CheckRangeEqArray
(
dst
,
ans
,
[](
const
NameAge
&
a
){
return
a
.
name
;});
}
}
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
TEST
(
WhereRange
,
MayToOne
)
TEST
(
WhereRange
,
MayToOne
)
{
{
...
@@ -108,7 +108,7 @@ TEST(WhereRange, ManyToZero)
...
@@ -108,7 +108,7 @@ TEST(WhereRange, ManyToZero)
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
.
next
Object
(),
LinqEndException
);
EXPECT_THROW
(
dst
.
next
(),
LinqEndException
);
}
}
TEST
(
WhereRange
,
OneToZero
)
TEST
(
WhereRange
,
OneToZero
)
...
@@ -118,7 +118,7 @@ TEST(WhereRange, OneToZero)
...
@@ -118,7 +118,7 @@ TEST(WhereRange, OneToZero)
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
.
next
Object
(),
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
.
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