Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_devices
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_devices
Commits
42d94097
Commit
42d94097
authored
9 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Added missing file
parent
3fb09a49
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/memory/HeapMemory_unit_tests.hpp
+89
-0
89 additions, 0 deletions
src/memory/HeapMemory_unit_tests.hpp
with
89 additions
and
0 deletions
src/memory/HeapMemory_unit_tests.hpp
0 → 100644
+
89
−
0
View file @
42d94097
/*
* HeapMemory_unit_tests.hpp
*
* Created on: Jul 9, 2015
* Author: i-bird
*/
#ifndef HEAPMEMORY_UNIT_TESTS_HPP_
#define HEAPMEMORY_UNIT_TESTS_HPP_
#include
"memory/HeapMemory.hpp"
#include
"memory/CudaMemory.cuh"
BOOST_AUTO_TEST_SUITE
(
HeapMemory_test
)
//! [Memory test constants]
#define FIRST_ALLOCATION 1024
#define SECOND_ALLOCATION 4096
//! [Memory test constants]
template
<
typename
T
>
void
test
()
{
//! [Allocate some memory and fill with data]
T
mem
;
mem
.
allocate
(
FIRST_ALLOCATION
);
BOOST_REQUIRE_EQUAL
(
mem
.
size
(),
FIRST_ALLOCATION
);
// get the pointer of the allocated memory and fill
unsigned
char
*
ptr
=
(
unsigned
char
*
)
mem
.
getPointer
();
for
(
size_t
i
=
0
;
i
<
mem
.
size
()
;
i
++
)
ptr
[
i
]
=
i
;
//! [Allocate some memory and fill with data]
//! [Resize the memory]
mem
.
resize
(
SECOND_ALLOCATION
);
unsigned
char
*
ptr2
=
(
unsigned
char
*
)
mem
.
getPointer
();
BOOST_REQUIRE_EQUAL
(
mem
.
size
(),
SECOND_ALLOCATION
);
BOOST_REQUIRE_EQUAL
(
mem
.
isInitialized
(),
false
);
//! [Resize the memory]
// check that the data are retained
for
(
size_t
i
=
0
;
i
<
FIRST_ALLOCATION
;
i
++
)
{
unsigned
char
c
=
i
;
BOOST_REQUIRE_EQUAL
(
ptr2
[
i
],
c
);
}
{
//! [Copy memory]
T
src
;
T
dst
;
src
.
allocate
(
FIRST_ALLOCATION
);
dst
.
allocate
(
SECOND_ALLOCATION
);
unsigned
char
*
ptr
=
(
unsigned
char
*
)
src
.
getPointer
();
for
(
size_t
i
=
0
;
i
<
src
.
size
()
;
i
++
)
ptr
[
i
]
=
i
;
dst
.
copy
(
src
);
for
(
size_t
i
=
0
;
i
<
FIRST_ALLOCATION
;
i
++
)
{
unsigned
char
c
=
i
;
BOOST_REQUIRE_EQUAL
(
ptr2
[
i
],
c
);
}
//! [Copy Memory]
}
}
BOOST_AUTO_TEST_CASE
(
use
)
{
test
<
HeapMemory
>
();
test
<
CudaMemory
>
();
}
BOOST_AUTO_TEST_SUITE_END
()
#endif
/* HEAPMEMORY_UNIT_TESTS_HPP_ */
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