Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
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
Package 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
Tobias Leibner
dune-common
Commits
b06152ea
Commit
b06152ea
authored
17 years ago
by
Markus Blatt
Browse files
Options
Downloads
Patches
Plain Diff
test for functionality in utility.hh
[[Imported from SVN: r5003]]
parent
4c3f60ab
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
common/test/.gitignore
+1
-0
1 addition, 0 deletions
common/test/.gitignore
common/test/Makefile.am
+5
-1
5 additions, 1 deletion
common/test/Makefile.am
common/test/utilitytest.cc
+92
-0
92 additions, 0 deletions
common/test/utilitytest.cc
with
98 additions
and
1 deletion
common/test/.gitignore
+
1
−
0
View file @
b06152ea
...
...
@@ -25,3 +25,4 @@ timing_flt
bigunsignedinttest
mpihelpertest
singletontest
utilitytest
This diff is collapsed.
Click to expand it.
common/test/Makefile.am
+
5
−
1
View file @
b06152ea
...
...
@@ -3,7 +3,8 @@
TESTPROGS
=
parsetest test-stack arraylisttest smartpointertest
\
sllisttest iteratorfacadetest tuplestest fvectortest fmatrixtest
\
poolallocatortest settest gcdlcdtest streamtest
\
bigunsignedinttest mpihelpertest singletontest mpicollcomm
bigunsignedinttest mpihelpertest singletontest mpicollcomm
\
utilitytest
# which tests to run
TESTS
=
$(
TESTPROGS
)
...
...
@@ -69,6 +70,9 @@ mpicollcomm_LDFLAGS = $(MPI_LDFLAGS) $(MPI_LIBS)
singletontest_SOURCES
=
singletontest.cc
singletontest_LDFLAGS
=
$(
LOCAL_LIBS
)
utilitytest_SOURCES
=
utilitytest.cc
utilitytest_LDFLAGS
=
$(
LOCAL_LIBS
)
sourcescheck_NOSOURCES
=
exprtmpl.cc timing.cc
include
$(top_srcdir)/am/global-rules
This diff is collapsed.
Click to expand it.
common/test/utilitytest.cc
0 → 100644
+
92
−
0
View file @
b06152ea
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include
<dune/common/tuples.hh>
#include
<dune/common/utility.hh>
#include
<iostream>
template
<
class
T
>
struct
Eval
{
typedef
void
*
Type
;
};
struct
Counter
{
Counter
()
:
result_
(
0
)
{}
template
<
class
T1
>
void
visit
(
T1
elem
)
{
++
result_
;
}
template
<
class
T1
,
class
T2
>
void
visit
(
T1
elem
,
T2
elem1
)
{
++
(
++
result_
);
}
int
result_
;
};
int
main
(
int
argc
,
char
**
argv
)
{
typedef
Dune
::
Tuple
<
int
*
,
double
*
,
long
*
,
char
*>
PointerTuple
;
Dune
::
Tuple
<
int
*
,
double
*
,
long
*
,
char
*>
pointers
=
Dune
::
NullPointerInitialiser
<
PointerTuple
>::
apply
();
int
ret
;
if
(
Dune
::
get
<
0
>
(
pointers
)
!=
0
)
{
std
::
cerr
<<
"First pointer not null"
<<
std
::
endl
;
ret
=
1
;
}
if
(
Dune
::
get
<
1
>
(
pointers
)
!=
0
)
{
std
::
cerr
<<
"Second pointer not null"
<<
std
::
endl
;
ret
=
2
;
}
if
(
Dune
::
get
<
2
>
(
pointers
)
!=
0
)
{
std
::
cerr
<<
"Third pointer not null"
<<
std
::
endl
;
ret
=
3
;
}
if
(
Dune
::
get
<
3
>
(
pointers
)
!=
0
)
{
std
::
cerr
<<
"Fourth pointer not null"
<<
std
::
endl
;
ret
=
4
;
}
int
i
=
3
;
int
*
ii
=&
i
;
double
d
=
2
;
long
l
=
4
;
char
c
=
's'
;
typedef
Dune
::
Tuple
<
int
*
,
char
*
,
long
*
,
char
*>
PointerTuple1
;
PointerTuple1
pointers1
(
&
i
,
&
c
,
&
l
,
&
c
);
if
(
static_cast
<
size_t
>
(
Dune
::
Length
<
PointerTuple
>::
value
)
!=
static_cast
<
size_t
>
(
Dune
::
tuple_size
<
PointerTuple
>::
value
))
{
std
::
cerr
<<
"Length and size do not match!"
<<
std
::
endl
;
}
Counter
count
;
Dune
::
ForEachValue
<
PointerTuple
>
forEach
(
pointers
);
forEach
.
apply
(
count
);
std
::
cout
<<
"Number of elements is: "
<<
count
.
result_
<<
std
::
endl
;
Dune
::
ForEachValuePair
<
PointerTuple
,
PointerTuple1
>
foreach1
(
pointers
,
pointers1
);
foreach1
.
apply
(
count
);
if
(
Dune
::
At
<
2
>::
get
(
pointers
)
!=
Dune
::
get
<
1
>
(
pointers
))
{
ret
+=
10
;
std
::
cerr
<<
"at inconsistent!"
<<
std
::
endl
;
}
PointerTuple1
p
(
new
int
(),
new
char
(),
new
long
(),
new
char
());
typedef
Dune
::
ForEachType
<
Eval
,
PointerTuple1
>::
Type
ConvertedType
;
Dune
::
PointerPairDeletor
<
PointerTuple1
>::
apply
(
p
);
return
ret
;
}
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