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
ad187c07
Commit
ad187c07
authored
May 24, 2016
by
Anton Bukov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17 from k06a/feature/travis-ci
Configure travis-ci.org service
parents
0de328bb
fc9be1c6
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
125 additions
and
80 deletions
+125
-80
.travis.yml
.travis.yml
+54
-0
CMakeLists.txt
benchmark/CMakeLists.txt
+10
-10
SpeedTest.cpp
benchmark/SpeedTest.cpp
+19
-18
gtest
externals/gtest
+1
-1
AvgTest.cpp
test/AvgTest.cpp
+3
-3
CMakeLists.txt
test/CMakeLists.txt
+10
-10
CommonTests.h
test/CommonTests.h
+7
-7
DistinctRangeTest.cpp
test/DistinctRangeTest.cpp
+2
-2
DotCallTest.cpp
test/DotCallTest.cpp
+6
-6
IterRangeTest.cpp
test/IterRangeTest.cpp
+2
-2
LinqTest.cpp
test/LinqTest.cpp
+6
-16
SelectRangeTest.cpp
test/SelectRangeTest.cpp
+1
-1
SumTest.cpp
test/SumTest.cpp
+1
-1
TakeWhileRangeTest.cpp
test/TakeWhileRangeTest.cpp
+1
-1
ToSetTest.cpp
test/ToSetTest.cpp
+1
-1
UnbytesRangeTest.cpp
test/UnbytesRangeTest.cpp
+1
-1
No files found.
.travis.yml
0 → 100644
View file @
ad187c07
language
:
none
sudo
:
false
cache
:
apt
:
true
directories
:
-
/tmp/tools
env
:
global
:
-
PATH="$HOME/bin:$PATH"
-
CMAKE_VERSION_PREFIX=3.5
-
CMAKE_VERSION_FULL=3.5.2
matrix
:
include
:
-
env
:
CXX=g++-5 CC=gcc-5
addons
:
apt
:
packages
:
-
g++-5
sources
:
&sources
-
ubuntu-toolchain-r-test
-
llvm-toolchain-precise-3.8
-
env
:
CXX=clang++-3.8 CC=clang-3.8
addons
:
apt
:
packages
:
-
clang-3.8
sources
:
*sources
before_install
:
-
pip install --user cpp-coveralls
install
:
-
mkdir -p /tmp/tools
-
pushd /tmp/tools
-
if [[ ! -f "cmake-$CMAKE_VERSION_FULL-Linux-x86_64.sh" ]]; then
curl -SOL "https://cmake.org/files/v$CMAKE_VERSION_PREFIX/cmake-$CMAKE_VERSION_FULL-Linux-x86_64.sh";
chmod +x "cmake-$CMAKE_VERSION_FULL-Linux-x86_64.sh";
fi
-
./"cmake-$CMAKE_VERSION_FULL-Linux-x86_64.sh" --prefix="$HOME" --exclude-subdir --skip-license
-
popd
script
:
-
mkdir build
-
cd build
-
cmake .. && make
-
./test/boolinqtest
-
./benchmark/boolinqbenchmark
-
cd ..
after_success
:
-
coveralls --gcov-options '\-lp'
benchmark/CMakeLists.txt
View file @
ad187c07
# Common variables.
# Common variables.
SET
(
CMAKE_BUILD_TYPE
"Release"
)
SET
(
CMAKE_BUILD_TYPE
Release
)
SET
(
CMAKE_CXX_
FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=gnu++11"
)
SET
(
CMAKE_CXX_
STANDARD 11
)
SET
(
CMAKE_CXX_
FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wmissing-include-dirs -Wundef -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations"
)
SET
(
CMAKE_CXX_
STANDARD_REQUIRED ON
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wdouble-promotion -Winit-self -Wvector-operation-performance -Wnoexcept -Weffc++ -Wstrict-null-sentinel
"
)
SET
(
TARGET boolinqbenchmark CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wmissing-include-dirs -Wfloat-equal -Wshadow
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Woverloaded-virtual -Wsign-promo
"
)
SET
(
TARGET boolinqbenchmark CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wdouble-promotion -Winit-self -Weffc++
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wvla -Winvalid-pch -Winline -Wredundant-decls
"
)
SET
(
TARGET boolinqbenchmark CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Woverloaded-virtual -Wsign-promo
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wlogical-op -Wcast-align
"
)
SET
(
TARGET boolinqbenchmark CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wvla -Winvalid-pch -Winline -Wredundant-decls
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wcast-qual -Wpointer-arith -Wtrampolines
"
)
SET
(
TARGET boolinqbenchmark CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wcast-align
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wold-style-cast
"
)
SET
(
TARGET boolinqbenchmark CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wcast-qual -Wpointer-arith
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wzero-as-null-pointer-constan
t"
)
SET
(
TARGET boolinqbenchmark CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wold-style-cas
t"
)
INCLUDE_DIRECTORIES
(
${
PROJECT_SOURCE_DIR
}
/externals/benchmark/include
)
INCLUDE_DIRECTORIES
(
${
PROJECT_SOURCE_DIR
}
/externals/benchmark/include
)
...
...
benchmark/SpeedTest.cpp
View file @
ad187c07
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <stdlib.h>
#include <stdlib.h>
#include <math.h>
#include "boolinq.h"
#include "boolinq.h"
...
@@ -38,17 +39,17 @@ int main (int argc, char ** argv)
...
@@ -38,17 +39,17 @@ int main (int argc, char ** argv)
static
void
BM_BoolinqCode
(
benchmark
::
State
&
state
)
static
void
BM_BoolinqCode
(
benchmark
::
State
&
state
)
{
{
while
(
state
.
KeepRunning
()
)
{
while
(
state
.
KeepRunning
()
)
{
double
avgValue
=
from
(
vecBoolinq
).
where
(
[](
int
a
){
return
a
%
2
==
1
;})
double
avgValue
=
from
(
vecBoolinq
).
where
([](
int
a
){
return
a
%
2
==
1
;})
.
avg
<
double
>
();
.
avg
();
double
disper
=
from
(
vecBoolinq
).
where
(
[](
int
a
){
return
a
%
2
==
1
;})
double
stdValue
=
from
(
vecBoolinq
).
where
(
[](
int
a
){
return
a
%
2
==
1
;})
.
select
([
=
](
int
a
){
return
(
double
)((
a
-
avgValue
)
*
(
a
-
avgValue
));})
.
avg
([
=
](
int
a
){
return
(
a
-
avgValue
)
*
(
a
-
avgValue
);});
.
avg
<
double
>
();
// It's no test, instead it's avoiding skip of calculation throgh optimization.
// It's no test, instead it's avoiding skip of calculation thro
u
gh optimization.
state
.
PauseTiming
();
state
.
PauseTiming
();
EXPECT_TRUE
(
avgValue
);
EXPECT_TRUE
(
avgValue
);
EXPECT_TRUE
(
disper
);
EXPECT_TRUE
(
stdValue
);
state
.
ResumeTiming
();
state
.
ResumeTiming
();
}
}
}
}
BENCHMARK
(
BM_BoolinqCode
);
BENCHMARK
(
BM_BoolinqCode
);
...
@@ -70,16 +71,16 @@ static void BM_CppCode (benchmark::State& state)
...
@@ -70,16 +71,16 @@ static void BM_CppCode (benchmark::State& state)
}
}
double
avgValue
=
sum
/
count
;
double
avgValue
=
sum
/
count
;
double
disper
Sum
=
0
;
double
std
Sum
=
0
;
for
(
unsigned
i
=
0
;
i
<
vecCpp
.
size
();
i
++
)
for
(
unsigned
i
=
0
;
i
<
vecCpp
.
size
();
i
++
)
if
(
vecCpp
[
i
]
%
2
==
1
)
if
(
vecCpp
[
i
]
%
2
==
1
)
disper
Sum
+=
(
vecCpp
[
i
]
-
avgValue
)
*
(
vecCpp
[
i
]
-
avgValue
);
std
Sum
+=
(
vecCpp
[
i
]
-
avgValue
)
*
(
vecCpp
[
i
]
-
avgValue
);
double
disper
=
disper
Sum
/
count
;
double
stdValue
=
std
Sum
/
count
;
// It's no test, instead it's avoiding skip of calculation throgh optimization.
// It's no test, instead it's avoiding skip of calculation thro
u
gh optimization.
state
.
PauseTiming
();
state
.
PauseTiming
();
EXPECT_TRUE
(
avgValue
);
EXPECT_TRUE
(
avgValue
);
EXPECT_TRUE
(
disper
);
EXPECT_TRUE
(
stdValue
);
state
.
ResumeTiming
();
state
.
ResumeTiming
();
}
}
}
}
...
@@ -102,16 +103,16 @@ static void BM_CppIterCode (benchmark::State& state)
...
@@ -102,16 +103,16 @@ static void BM_CppIterCode (benchmark::State& state)
}
}
double
avgValue
=
sum
/
count
;
double
avgValue
=
sum
/
count
;
double
disper
Sum
=
0
;
double
std
Sum
=
0
;
for
(
auto
it
=
vecCppIter
.
begin
();
it
!=
vecCppIter
.
end
();
++
it
)
for
(
auto
it
=
vecCppIter
.
begin
();
it
!=
vecCppIter
.
end
();
++
it
)
if
(
*
it
%
2
==
1
)
if
(
*
it
%
2
==
1
)
disper
Sum
+=
(
*
it
-
avgValue
)
*
(
*
it
-
avgValue
);
std
Sum
+=
(
*
it
-
avgValue
)
*
(
*
it
-
avgValue
);
double
disper
=
disper
Sum
/
count
;
double
stdValue
=
std
Sum
/
count
;
// It's no test, instead it's avoiding skip of calculation throgh optimization.
// It's no test, instead it's avoiding skip of calculation thro
u
gh optimization.
state
.
PauseTiming
();
state
.
PauseTiming
();
EXPECT_TRUE
(
avgValue
);
EXPECT_TRUE
(
avgValue
);
EXPECT_TRUE
(
disper
);
EXPECT_TRUE
(
stdValue
);
state
.
ResumeTiming
();
state
.
ResumeTiming
();
}
}
}
}
...
...
gtest
@
d225acc9
Subproject commit
0a439623f75c029912728d80cb7f1b8b48739ca4
Subproject commit
d225acc90bc3a8c420a9bcd1f033033c1ccd7fe0
test/AvgTest.cpp
View file @
ad187c07
...
@@ -16,7 +16,7 @@ TEST(Avg, ThreeInts)
...
@@ -16,7 +16,7 @@ TEST(Avg, ThreeInts)
auto
rng
=
from
(
src
);
auto
rng
=
from
(
src
);
EXPECT_
EQ
(
2
,
rng
.
avg
<
double
>
()
);
EXPECT_
NEAR
(
2.0
,
rng
.
avg
<
double
>
(),
DBL_EPSILON
);
}
}
TEST
(
Avg
,
FiveInts
)
TEST
(
Avg
,
FiveInts
)
...
@@ -32,8 +32,8 @@ TEST(Avg, FiveInts)
...
@@ -32,8 +32,8 @@ TEST(Avg, FiveInts)
auto
dst0
=
rng
.
where
([](
int
a
){
return
a
%
2
==
0
;});
auto
dst0
=
rng
.
where
([](
int
a
){
return
a
%
2
==
0
;});
auto
dst1
=
rng
.
where
([](
int
a
){
return
a
%
2
==
1
;});
auto
dst1
=
rng
.
where
([](
int
a
){
return
a
%
2
==
1
;});
EXPECT_
EQ
(
3
,
dst0
.
avg
<
double
>
()
);
EXPECT_
NEAR
(
3.0
,
dst0
.
avg
<
double
>
(),
DBL_EPSILON
);
EXPECT_
EQ
(
3
,
dst1
.
avg
<
double
>
()
);
EXPECT_
NEAR
(
3.0
,
dst1
.
avg
<
double
>
(),
DBL_EPSILON
);
}
}
TEST
(
Avg
,
FiveStringsLen
)
TEST
(
Avg
,
FiveStringsLen
)
...
...
test/CMakeLists.txt
View file @
ad187c07
# Common variables.
# Common variables.
SET
(
CMAKE_CXX_
FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=gnu++11"
)
SET
(
CMAKE_CXX_
STANDARD 11
)
SET
(
CMAKE_CXX_
FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wmissing-include-dirs -Wundef -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations"
)
SET
(
CMAKE_CXX_
STANDARD_REQUIRED ON
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wdouble-promotion -Winit-self -Wvector-operation-performance -Wnoexcept -Weffc++ -Wstrict-null-sentinel
"
)
SET
(
TARGET boolinqtest CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wmissing-include-dirs -Wfloat-equal -Wshadow
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Woverloaded-virtual -Wsign-promo
"
)
SET
(
TARGET boolinqtest CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wdouble-promotion -Winit-self -Weffc++
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wvla -Winvalid-pch -Winline -Wredundant-decls
"
)
SET
(
TARGET boolinqtest CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Woverloaded-virtual -Wsign-promo
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wlogical-op -Wcast-align
"
)
SET
(
TARGET boolinqtest CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wvla -Winvalid-pch -Winline -Wredundant-decls
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wcast-qual -Wpointer-arith -Wtrampolines
"
)
SET
(
TARGET boolinqtest CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wcast-align
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wold-style-cast
"
)
SET
(
TARGET boolinqtest CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wcast-qual -Wpointer-arith
"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wzero-as-null-pointer-constan
t"
)
SET
(
TARGET boolinqtest CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wold-style-cas
t"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fprofile-arcs -ftest-coverage"
)
SET
(
TARGET boolinqtest
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fprofile-arcs -ftest-coverage"
)
SET
(
CMAKE_SHARED_LINKER_FLAGS
"-fprofile-arcs -ftest-coverage"
)
SET
(
CMAKE_SHARED_LINKER_FLAGS
"-fprofile-arcs -ftest-coverage"
)
...
...
test/CommonTests.h
View file @
ad187c07
...
@@ -10,29 +10,29 @@ using namespace boolinq;
...
@@ -10,29 +10,29 @@ using namespace boolinq;
// Compare Range with array
// Compare Range with array
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
template
<
typename
R
,
typename
T
,
int
N
,
typename
F
>
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
(
int
i
=
0
;
i
<
N
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
N
;
i
++
)
EXPECT_EQ
(
f
(
ans
[
i
]),
f
(
dst
.
nextObject
()));
EXPECT_EQ
(
f
(
ans
[
i
]),
f
(
dst
.
nextObject
()));
EXPECT_THROW
(
dst
.
nextObject
(),
EnumeratorEndException
);
EXPECT_THROW
(
dst
.
nextObject
(),
EnumeratorEndException
);
}
}
template
<
typename
R
,
typename
T
,
int
N
>
template
<
typename
R
,
typename
T
,
unsigned
N
>
void
CheckRangeEqArray
(
R
dst
,
T
(
&
ans
)[
N
])
void
CheckRangeEqArray
(
R
dst
,
T
(
&
ans
)[
N
])
{
{
for
(
int
i
=
0
;
i
<
N
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
N
;
i
++
)
EXPECT_EQ
(
ans
[
i
],
dst
.
nextObject
());
EXPECT_EQ
(
ans
[
i
],
dst
.
nextObject
());
EXPECT_THROW
(
dst
.
nextObject
(),
EnumeratorEndException
);
EXPECT_THROW
(
dst
.
nextObject
(),
EnumeratorEndException
);
}
}
template
<
typename
T
,
int
N
>
template
<
typename
T
,
unsigned
N
>
std
::
set
<
T
>
ArrayToSet
(
T
(
&
ans
)[
N
])
std
::
set
<
T
>
ArrayToSet
(
T
(
&
ans
)[
N
])
{
{
std
::
set
<
T
>
res
;
std
::
set
<
T
>
res
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
N
;
i
++
)
res
.
insert
(
ans
[
i
]);
res
.
insert
(
ans
[
i
]);
EXPECT_EQ
(
N
,
res
.
size
());
EXPECT_EQ
(
N
,
res
.
size
());
...
@@ -40,7 +40,7 @@ std::set<T> ArrayToSet(T (&ans)[N])
...
@@ -40,7 +40,7 @@ std::set<T> ArrayToSet(T (&ans)[N])
return
res
;
return
res
;
}
}
template
<
typename
R
,
typename
T
,
int
N
>
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
);
...
...
test/DistinctRangeTest.cpp
View file @
ad187c07
...
@@ -72,9 +72,9 @@ TEST(DistinctRange, OneFieldFront)
...
@@ -72,9 +72,9 @@ TEST(DistinctRange, OneFieldFront)
return
(
name
==
man
.
name
);
return
(
name
==
man
.
name
);
}
}
bool
operator
==
(
const
std
::
string
&
n
ame
)
const
bool
operator
==
(
const
std
::
string
&
manN
ame
)
const
{
{
return
(
this
->
name
==
n
ame
);
return
(
this
->
name
==
manN
ame
);
}
}
};
};
...
...
test/DotCallTest.cpp
View file @
ad187c07
...
@@ -47,9 +47,9 @@ TEST(DotCall, UnbytesRange)
...
@@ -47,9 +47,9 @@ TEST(DotCall, UnbytesRange)
unsigned
ansFL
[]
=
{
0x12345678
,
0xAABBCCDD
};
unsigned
ansFL
[]
=
{
0x12345678
,
0xAABBCCDD
};
unsigned
ansLF
[]
=
{
0x78563412
,
0xDDCCBBAA
};
unsigned
ansLF
[]
=
{
0x78563412
,
0xDDCCBBAA
};
auto
dstFL1
=
from
(
src
).
unbytes
<
int
>
();
auto
dstFL1
=
from
(
src
).
unbytes
<
unsigned
>
();
auto
dstFL2
=
from
(
src
).
unbytes
<
int
>
(
FirstToLast
);
auto
dstFL2
=
from
(
src
).
unbytes
<
unsigned
>
(
FirstToLast
);
auto
dstLF1
=
from
(
src
).
unbytes
<
int
>
(
LastToFirst
);
auto
dstLF1
=
from
(
src
).
unbytes
<
unsigned
>
(
LastToFirst
);
CheckRangeEqArray
(
dstFL1
,
ansFL
);
CheckRangeEqArray
(
dstFL1
,
ansFL
);
CheckRangeEqArray
(
dstFL2
,
ansFL
);
CheckRangeEqArray
(
dstFL2
,
ansFL
);
...
@@ -131,9 +131,9 @@ TEST(DotCall, UnbitsRangeHLFL)
...
@@ -131,9 +131,9 @@ TEST(DotCall, UnbitsRangeHLFL)
auto
dst1_4b
=
from
(
src
).
unbits
();
auto
dst1_4b
=
from
(
src
).
unbits
();
auto
dst2_4b
=
from
(
src
).
unbits
(
HighToLow
);
auto
dst2_4b
=
from
(
src
).
unbits
(
HighToLow
);
auto
dst1_1i
=
from
(
src
).
unbits
<
int
>
(
HighToLow
);
auto
dst1_1i
=
from
(
src
).
unbits
<
unsigned
>
(
HighToLow
);
auto
dst2_1i
=
from
(
src
).
unbits
<
int
>
(
HighToLow
,
FirstToLast
);
auto
dst2_1i
=
from
(
src
).
unbits
<
unsigned
>
(
HighToLow
,
FirstToLast
);
auto
dst3_1i
=
from
(
src
).
unbits
<
int
>
(
HighToLow
,
LastToFirst
);
auto
dst3_1i
=
from
(
src
).
unbits
<
unsigned
>
(
HighToLow
,
LastToFirst
);
CheckRangeEqArray
(
dst1_4b
,
ans_4b
);
CheckRangeEqArray
(
dst1_4b
,
ans_4b
);
CheckRangeEqArray
(
dst2_4b
,
ans_4b
);
CheckRangeEqArray
(
dst2_4b
,
ans_4b
);
...
...
test/IterRangeTest.cpp
View file @
ad187c07
...
@@ -88,7 +88,7 @@ TEST(IterRange, MapInt)
...
@@ -88,7 +88,7 @@ TEST(IterRange, MapInt)
TEST
(
IterRange
,
StdArrayInt
)
TEST
(
IterRange
,
StdArrayInt
)
{
{
std
::
array
<
int
,
5
>
arr
=
{
1
,
2
,
3
,
4
,
5
};
std
::
array
<
int
,
5
>
arr
=
{
{
1
,
2
,
3
,
4
,
5
}
};
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
CheckRangeEqArray
(
from
(
arr
),
ans
);
CheckRangeEqArray
(
from
(
arr
),
ans
);
...
@@ -99,7 +99,7 @@ TEST(IterRange, StdArrayInt)
...
@@ -99,7 +99,7 @@ TEST(IterRange, StdArrayInt)
TEST
(
IterRange
,
ArrayInt
)
TEST
(
IterRange
,
ArrayInt
)
{
{
int
arr
[]
=
{
1
,
2
,
3
,
4
,
5
};
int
arr
[]
=
{
1
,
2
,
3
,
4
,
5
};
int
*
ptr
=
(
int
*
)
arr
;
int
*
ptr
=
static_cast
<
int
*>
(
arr
)
;
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
int
ans
[]
=
{
1
,
2
,
3
,
4
,
5
};
...
...
test/LinqTest.cpp
View file @
ad187c07
...
@@ -208,7 +208,7 @@ TEST(Linq, Pointer_Front)
...
@@ -208,7 +208,7 @@ TEST(Linq, Pointer_Front)
{
{
int
src
[]
=
{
1
,
2
,
3
,
4
,
5
};
int
src
[]
=
{
1
,
2
,
3
,
4
,
5
};
auto
dst
=
from
<
int
>
(
(
int
*
)
src
,
(
int
*
)
src
+
5
);
auto
dst
=
from
<
int
>
(
static_cast
<
int
*>
(
src
),
static_cast
<
int
*>
(
src
)
+
5
);
for
(
int
i
=
1
;
i
<=
5
;
i
++
)
for
(
int
i
=
1
;
i
<=
5
;
i
++
)
{
{
...
@@ -246,19 +246,11 @@ TEST(Linq, Creations)
...
@@ -246,19 +246,11 @@ TEST(Linq, Creations)
vec
.
push_back
(
4
);
vec
.
push_back
(
4
);
vec
.
push_back
(
5
);
vec
.
push_back
(
5
);
int
arr
[]
=
{
1
,
2
,
3
,
4
,
5
};
int
arr
[]
=
{
1
,
2
,
3
,
4
,
5
};
int
*
ptr
=
(
int
*
)
arr
;
//const int carr[] = {1,2,3,4,5};
int
*
ptr
=
static_cast
<
int
*>
(
arr
);
//std::vector<const int> cvec;
//const int * cptr = const_cast<int *>(arr);
//cvec.push_back(1);
//cvec.push_back(2);
//cvec.push_back(3);
//cvec.push_back(4);
//cvec.push_back(5);
const
int
carr
[]
=
{
1
,
2
,
3
,
4
,
5
};
const
int
*
cptr
=
(
const
int
*
)
carr
;
auto
dst_vec
=
from
(
vec
);
auto
dst_vec
=
from
(
vec
);
//auto dst_cvec = from(cvec);
auto
dst_arr
=
from
(
arr
);
auto
dst_arr
=
from
(
arr
);
//auto dst_carr = from(carr);
//auto dst_carr = from(carr);
auto
dst_ptr
=
from
<
int
>
(
ptr
,
ptr
+
5
);
auto
dst_ptr
=
from
<
int
>
(
ptr
,
ptr
+
5
);
...
@@ -267,8 +259,6 @@ TEST(Linq, Creations)
...
@@ -267,8 +259,6 @@ TEST(Linq, Creations)
//auto dst_cptr_length = from<const int>(cptr, 5);
//auto dst_cptr_length = from<const int>(cptr, 5);
auto
dst_vec_iter
=
from
<
int
>
(
vec
.
begin
(),
vec
.
end
());
auto
dst_vec_iter
=
from
<
int
>
(
vec
.
begin
(),
vec
.
end
());
//auto dst_vec_citer = from<const int>(vec.cbegin(), vec.cend());
//auto dst_vec_citer = from<const int>(vec.cbegin(), vec.cend());
//auto dst_cvec_iter = from<const int>(cvec.begin(), cvec.end());
//auto dst_cvec_citer = from<const int>(cvec.cbegin(), cvec.cend());
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
...
@@ -284,8 +274,8 @@ TEST(Linq, MessagesCountUniqueContacts)
...
@@ -284,8 +274,8 @@ TEST(Linq, MessagesCountUniqueContacts)
bool
operator
<
(
const
Message
&
rhs
)
const
bool
operator
<
(
const
Message
&
rhs
)
const
{
{
return
(
PhoneA
<
rhs
.
PhoneA
)
return
(
PhoneA
<
rhs
.
PhoneA
)
||
(
PhoneA
==
rhs
.
PhoneA
)
&&
(
PhoneB
<
rhs
.
PhoneB
)
||
(
(
PhoneA
==
rhs
.
PhoneA
)
&&
(
PhoneB
<
rhs
.
PhoneB
)
)
||
(
PhoneA
==
rhs
.
PhoneA
)
&&
(
PhoneB
==
rhs
.
PhoneB
)
&&
(
Text
<
rhs
.
Text
);
||
(
(
PhoneA
==
rhs
.
PhoneA
)
&&
(
PhoneB
==
rhs
.
PhoneB
)
&&
(
Text
<
rhs
.
Text
)
);
}
}
};
};
...
...
test/SelectRangeTest.cpp
View file @
ad187c07
...
@@ -25,7 +25,7 @@ TEST(SelectRange, MakeChar)
...
@@ -25,7 +25,7 @@ TEST(SelectRange, MakeChar)
char
ans
[]
=
{
'1'
,
'2'
,
'3'
,
'4'
};
char
ans
[]
=
{
'1'
,
'2'
,
'3'
,
'4'
};
auto
rng
=
from
(
src
);
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
select
([](
int
a
){
return
(
char
)(
a
+
'0'
);});
auto
dst
=
rng
.
select
([](
int
a
){
return
static_cast
<
char
>
(
'0'
+
a
);});
CheckRangeEqArray
(
dst
,
ans
);
CheckRangeEqArray
(
dst
,
ans
);
}
}
...
...
test/SumTest.cpp
View file @
ad187c07
...
@@ -63,7 +63,7 @@ TEST(Sum, FiveStringsLen)
...
@@ -63,7 +63,7 @@ TEST(Sum, FiveStringsLen)
auto
rng
=
from
(
src
).
sum
([](
const
std
::
string
&
str
){
return
str
.
size
();});
auto
rng
=
from
(
src
).
sum
([](
const
std
::
string
&
str
){
return
str
.
size
();});
EXPECT_EQ
(
26
,
rng
);
EXPECT_EQ
(
26
U
,
rng
);
}
}
TEST
(
Sum
,
FiveStringsData
)
TEST
(
Sum
,
FiveStringsData
)
...
...
test/TakeWhileRangeTest.cpp
View file @
ad187c07
...
@@ -93,7 +93,7 @@ TEST(TakeWhileRange_i, ManyToManyByIndexAndItemValue)
...
@@ -93,7 +93,7 @@ TEST(TakeWhileRange_i, ManyToManyByIndexAndItemValue)
int
ans
[]
=
{
1
,
3
,
5
,
7
,
9
,
11
};
int
ans
[]
=
{
1
,
3
,
5
,
7
,
9
,
11
};
auto
rng
=
from
(
src
);
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
takeWhile_i
([](
int
it
,
int
idx
){
return
idx
<
3
||
it
>
5
&&
it
<
12
;});
auto
dst
=
rng
.
takeWhile_i
([](
int
it
,
int
idx
){
return
idx
<
3
||
(
it
>
5
&&
it
<
12
)
;});
CheckRangeEqArray
(
dst
,
ans
);
CheckRangeEqArray
(
dst
,
ans
);
}
}
...
...
test/ToSetTest.cpp
View file @
ad187c07
...
@@ -18,7 +18,7 @@ TEST(ToSet, Vector2Set)
...
@@ -18,7 +18,7 @@ TEST(ToSet, Vector2Set)
auto
rng
=
from
(
src
);
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
toSet
();
auto
dst
=
rng
.
toSet
();
EXPECT_EQ
(
3
,
dst
.
size
());
EXPECT_EQ
(
3
U
,
dst
.
size
());
EXPECT_NE
(
dst
.
end
(),
dst
.
find
(
1
));
EXPECT_NE
(
dst
.
end
(),
dst
.
find
(
1
));
EXPECT_NE
(
dst
.
end
(),
dst
.
find
(
2
));
EXPECT_NE
(
dst
.
end
(),
dst
.
find
(
2
));
EXPECT_NE
(
dst
.
end
(),
dst
.
find
(
3
));
EXPECT_NE
(
dst
.
end
(),
dst
.
find
(
3
));
...
...
test/UnbytesRangeTest.cpp
View file @
ad187c07
...
@@ -16,7 +16,7 @@ TEST(UnbytesRange, OneIntDefault)
...
@@ -16,7 +16,7 @@ TEST(UnbytesRange, OneIntDefault)
unsigned
ans
[]
=
{
0xDDCCBBAA
};
unsigned
ans
[]
=
{
0xDDCCBBAA
};
auto
rng
=
from
(
src
);
auto
rng
=
from
(
src
);
auto
dst
=
rng
.
unbytes
<
int
>
();
auto
dst
=
rng
.
unbytes
<
unsigned
>
();
CheckRangeEqArray
(
dst
,
ans
);
CheckRangeEqArray
(
dst
,
ans
);
}
}
...
...
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