Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
16703ff8
Unverified
Commit
16703ff8
authored
May 29, 2018
by
Dominic Hamon
Committed by
GitHub
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaner and slightly larger statistics tests (#604)
parent
c8adf453
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
43 deletions
+10
-43
statistics_gtest.cc
test/statistics_gtest.cc
+10
-43
No files found.
test/statistics_gtest.cc
View file @
16703ff8
...
...
@@ -7,55 +7,22 @@
namespace
{
TEST
(
StatisticsTest
,
Mean
)
{
std
::
vector
<
double
>
Inputs
;
{
Inputs
=
{
42
,
42
,
42
,
42
};
double
Res
=
benchmark
::
StatisticsMean
(
Inputs
);
EXPECT_DOUBLE_EQ
(
Res
,
42.0
);
}
{
Inputs
=
{
1
,
2
,
3
,
4
};
double
Res
=
benchmark
::
StatisticsMean
(
Inputs
);
EXPECT_DOUBLE_EQ
(
Res
,
2.5
);
}
{
Inputs
=
{
1
,
2
,
5
,
10
,
10
,
14
};
double
Res
=
benchmark
::
StatisticsMean
(
Inputs
);
EXPECT_DOUBLE_EQ
(
Res
,
7.0
);
}
EXPECT_DOUBLE_EQ
(
benchmark
::
StatisticsMean
({
42
,
42
,
42
,
42
}),
42.0
);
EXPECT_DOUBLE_EQ
(
benchmark
::
StatisticsMean
({
1
,
2
,
3
,
4
}),
2.5
);
EXPECT_DOUBLE_EQ
(
benchmark
::
StatisticsMean
({
1
,
2
,
5
,
10
,
10
,
14
}),
7.0
);
}
TEST
(
StatisticsTest
,
Median
)
{
std
::
vector
<
double
>
Inputs
;
{
Inputs
=
{
42
,
42
,
42
,
42
};
double
Res
=
benchmark
::
StatisticsMedian
(
Inputs
);
EXPECT_DOUBLE_EQ
(
Res
,
42.0
);
}
{
Inputs
=
{
1
,
2
,
3
,
4
};
double
Res
=
benchmark
::
StatisticsMedian
(
Inputs
);
EXPECT_DOUBLE_EQ
(
Res
,
2.5
);
}
{
Inputs
=
{
1
,
2
,
5
,
10
,
10
};
double
Res
=
benchmark
::
StatisticsMedian
(
Inputs
);
EXPECT_DOUBLE_EQ
(
Res
,
5.0
);
}
EXPECT_DOUBLE_EQ
(
benchmark
::
StatisticsMedian
({
42
,
42
,
42
,
42
}),
42.0
);
EXPECT_DOUBLE_EQ
(
benchmark
::
StatisticsMedian
({
1
,
2
,
3
,
4
}),
2.5
);
EXPECT_DOUBLE_EQ
(
benchmark
::
StatisticsMedian
({
1
,
2
,
5
,
10
,
10
}),
5.0
);
}
TEST
(
StatisticsTest
,
StdDev
)
{
std
::
vector
<
double
>
Inputs
;
{
Inputs
=
{
101
,
101
,
101
,
101
};
double
Res
=
benchmark
::
StatisticsStdDev
(
Inputs
);
EXPECT_DOUBLE_EQ
(
Res
,
0.0
);
}
{
Inputs
=
{
1
,
2
,
3
};
double
Res
=
benchmark
::
StatisticsStdDev
(
Inputs
);
EXPECT_DOUBLE_EQ
(
Res
,
1.0
);
}
EXPECT_DOUBLE_EQ
(
benchmark
::
StatisticsStdDev
({
101
,
101
,
101
,
101
}),
0.0
);
EXPECT_DOUBLE_EQ
(
benchmark
::
StatisticsStdDev
({
1
,
2
,
3
}),
1.0
);
EXPECT_FLOAT_EQ
(
benchmark
::
StatisticsStdDev
({
1.5
,
2.4
,
3.3
,
4.2
,
5.1
}),
1.42302495
);
}
}
// end namespace
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