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
159c4f3e
Commit
159c4f3e
authored
10 years ago
by
Joseph Mirabel
Committed by
Joseph Mirabel
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add tests
parent
33016bd8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
tests/CMakeLists.txt
+41
-0
41 additions, 0 deletions
tests/CMakeLists.txt
tests/test-successstatistics.cc
+60
-0
60 additions, 0 deletions
tests/test-successstatistics.cc
with
102 additions
and
0 deletions
CMakeLists.txt
+
1
−
0
View file @
159c4f3e
...
...
@@ -44,5 +44,6 @@ SET (${PROJECT_NAME}_HEADERS
PKG_CONFIG_APPEND_LIBS
(
"hpp-statistics"
)
ADD_SUBDIRECTORY
(
src
)
ADD_SUBDIRECTORY
(
tests
)
SETUP_PROJECT_FINALIZE
()
This diff is collapsed.
Click to expand it.
tests/CMakeLists.txt
0 → 100644
+
41
−
0
View file @
159c4f3e
# Copyright 2012, 2013, 2014 CNRS-LAAS
#
# Author: Mathieu Geisert
#
# This file is part of hpp-core
# hpp-model-urdf 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-core 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-core If not, see <http://www.gnu.org/licenses/>.
# ADD_TESTCASE(NAME)
# ------------------------
#
# Define a test named `NAME'.
#
# This macro will create a binary from `NAME.cc', link it against
# Boost and add it to the test suite.
#
MACRO
(
ADD_TESTCASE NAME GENERATED
)
IF
(
${
GENERATED
}
STREQUAL TRUE
)
ADD_EXECUTABLE
(
${
NAME
}
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
NAME
}
.cc
)
ELSE
()
ADD_EXECUTABLE
(
${
NAME
}
${
NAME
}
.cc
)
ENDIF
()
ADD_TEST
(
${
NAME
}
${
RUNTIME_OUTPUT_DIRECTORY
}
/
${
NAME
}
)
# Link against Boost and project library.
TARGET_LINK_LIBRARIES
(
${
NAME
}
${
PROJECT_NAME
}
)
ENDMACRO
(
ADD_TESTCASE
)
ADD_TESTCASE
(
test-successstatistics FALSE
)
This diff is collapsed.
Click to expand it.
tests/test-successstatistics.cc
0 → 100644
+
60
−
0
View file @
159c4f3e
// 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
<stdlib.h>
#include
<time.h>
#include
<iostream>
#include
"hpp/statistics/success-bin.hh"
HPP_DEFINE_REASON_FAILURE
(
REASON_TEST
,
"Fake reason for testing purpose"
);
int
main
()
{
/* initialize random seed: */
srand
(
time
(
NULL
));
using
namespace
hpp
::
statistics
;
SuccessStatistics
ss
;
unsigned
int
counter
[
3
];
counter
[
0
]
=
0
;
counter
[
1
]
=
0
;
counter
[
2
]
=
0
;
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
unsigned
int
nb
=
rand
()
%
3
;
counter
[
nb
]
++
;
switch
(
nb
)
{
case
0
:
ss
.
addSuccess
();
break
;
case
1
:
ss
.
addFailure
();
break
;
case
2
:
ss
.
addFailure
(
REASON_TEST
);
break
;
}
}
if
(
ss
.
nbSuccess
()
!=
counter
[
0
]
||
ss
.
nbFailure
(
SuccessBin
::
REASON_UNKNOWN
)
!=
counter
[
1
]
||
ss
.
nbFailure
(
REASON_TEST
)
!=
counter
[
2
])
{
std
::
cout
<<
ss
;
std
::
cout
<<
"Real frequencies are: ( "
<<
counter
[
0
]
<<
", "
<<
counter
[
1
]
<<
", "
<<
counter
[
2
]
<<
")"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
if
(
ss
.
nbFailure
()
!=
counter
[
1
]
+
counter
[
2
])
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