Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
ScalFMM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
solverstack
ScalFMM
Commits
a8e472fa
Commit
a8e472fa
authored
11 years ago
by
BRAMAS Berenger
Browse files
Options
Downloads
Patches
Plain Diff
add utest for allocator
parent
45a79f16
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
UTests/utestListBlockAllocator.cpp
+103
-0
103 additions, 0 deletions
UTests/utestListBlockAllocator.cpp
with
103 additions
and
0 deletions
UTests/utestListBlockAllocator.cpp
0 → 100644
+
103
−
0
View file @
a8e472fa
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// This program 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 Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#include
"FUTester.hpp"
#include
"../Src/Containers/FBlockAllocator.hpp"
#include
<cstring>
/**
* This file is a unit test for the List block allocator
*/
/**
* This class is simply used to count alloc dealloc
*/
class
TestObject
{
public:
static
int
counter
;
static
int
dealloced
;
int
array
[
50
];
TestObject
(){
memset
(
array
,
0
,
50
*
sizeof
(
int
));
++
counter
;
}
TestObject
(
const
TestObject
&
){
++
counter
;
}
~
TestObject
(){
++
dealloced
;
}
};
int
TestObject
::
counter
(
0
);
int
TestObject
::
dealloced
(
0
);
/** this class test the list container */
class
TestBlock
:
public
FUTester
<
TestBlock
>
{
// Called before each test : simply set counter to 0
void
PreTest
(){
TestObject
::
counter
=
0
;
TestObject
::
dealloced
=
0
;
}
// test copy
void
TestBlockFunction
(){
FListBlockAllocator
<
TestObject
,
10
>
alloc
;
TestObject
*
ptr
[
100
];
for
(
int
idx
=
0
;
idx
<
100
;
++
idx
){
TestObject
*
dl1
=
alloc
.
newObject
();
TestObject
*
dl2
=
alloc
.
newObject
();
alloc
.
deleteObject
(
dl1
);
ptr
[
idx
]
=
alloc
.
newObject
();
alloc
.
deleteObject
(
dl2
);
}
for
(
int
idx
=
0
;
idx
<
100
;
++
idx
){
for
(
int
idxval
=
0
;
idxval
<
50
;
++
idxval
){
ptr
[
idx
]
->
array
[
idxval
]
+=
(
idxval
*
idx
);
}
}
for
(
int
idx
=
0
;
idx
<
100
;
++
idx
){
for
(
int
idxval
=
0
;
idxval
<
50
;
++
idxval
){
uassert
(
ptr
[
idx
]
->
array
[
idxval
]
==
(
idxval
*
idx
));
}
}
for
(
int
idx
=
0
;
idx
<
100
;
++
idx
){
alloc
.
deleteObject
(
ptr
[
idx
]);
}
uassert
(
TestObject
::
counter
==
300
);
uassert
(
TestObject
::
counter
==
TestObject
::
dealloced
);
}
// set test
void
SetTests
(){
AddTest
(
&
TestBlock
::
TestBlockFunction
,
"Test Allocate Deallocate"
);
}
};
// You must do this
TestClass
(
TestBlock
)
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