Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hpp-statistics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Humanoid Path Planner
hpp-statistics
Commits
03f78a30
Commit
03f78a30
authored
10 years ago
by
Joseph Mirabel
Committed by
Joseph Mirabel
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a test
parent
a5c00e30
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/test-statistics.cc
+79
-0
79 additions, 0 deletions
tests/test-statistics.cc
with
80 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
03f78a30
...
...
@@ -40,3 +40,4 @@ ENDMACRO(ADD_TESTCASE)
ADD_TESTCASE
(
test-successstatistics FALSE
)
ADD_TESTCASE
(
test-distribution FALSE
)
ADD_TESTCASE
(
test-statistics FALSE
)
This diff is collapsed.
Click to expand it.
tests/test-statistics.cc
0 → 100644
+
79
−
0
View file @
03f78a30
// Copyright (c) 2014, LAAS-CNRS
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
//
// This file is part of hpp-statistics.
// hpp-statistics is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-statistics is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-statistics. If not, see <http://www.gnu.org/licenses/>.
#include
<iostream>
#include
<time.h>
#include
<stdlib.h>
#include
<list>
#include
"hpp/statistics/bin.hh"
using
hpp
::
statistics
::
Bin
;
using
hpp
::
statistics
::
Statistics
;
class
TestBin
:
public
Bin
{
public:
int
val
;
std
::
list
<
double
>
l
;
TestBin
(
int
i
)
:
val
(
i
)
{}
std
::
ostream
&
printValue
(
std
::
ostream
&
os
)
const
{
os
<<
val
<<
" has :"
;
for
(
std
::
list
<
double
>::
const_iterator
it
=
l
.
begin
();
it
!=
l
.
end
();
it
++
)
os
<<
" "
<<
*
it
<<
std
::
endl
;
return
os
<<
std
::
endl
;
}
bool
operator
<
(
const
TestBin
&
rhs
)
const
{
return
val
<
rhs
.
val
;
}
bool
operator
==
(
const
TestBin
&
rhs
)
const
{
return
val
==
rhs
.
val
;
}
};
class
TestStatistics
:
public
Statistics
<
TestBin
>
{
public:
void
add
(
int
n
,
double
d
)
{
TestBin
b
(
n
);
TestStatistics
::
iterator
it
=
insert
(
b
);
it
->
l
.
push_back
(
d
);
}
};
int
main
()
{
srand
(
time
(
NULL
));
TestStatistics
t
;
double
*
check
=
new
double
[
100
];
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
check
[
i
]
=
((
double
)(
rand
())
/
(
double
)
rand
());
t
.
add
(
i
,
check
[
i
]);
}
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
TestStatistics
::
const_iterator
it
=
t
.
find
(
i
);
if
(
it
==
t
.
end
())
return
EXIT_FAILURE
;
if
(
it
->
l
.
size
()
!=
1
&&
check
[
i
]
!=
it
->
l
.
front
())
return
EXIT_FAILURE
;
}
return
EXIT_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment