Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
ag-ohlberger
dune-community
dune-xt
Commits
09fa8122
Commit
09fa8122
authored
10 years ago
by
Dr. Felix Tobias Schindler
Browse files
Options
Downloads
Patches
Plain Diff
[test] moved main.hh -> main.hxx, refs
#11
parent
7a8337eb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/stuff/test/main.hh
+2
-159
2 additions, 159 deletions
dune/stuff/test/main.hh
dune/stuff/test/main.hxx
+165
-0
165 additions, 0 deletions
dune/stuff/test/main.hxx
with
167 additions
and
159 deletions
dune/stuff/test/main.hh
+
2
−
159
View file @
09fa8122
...
@@ -3,163 +3,6 @@
...
@@ -3,163 +3,6 @@
// Copyright holders: Rene Milk, Felix Schindler
// Copyright holders: Rene Milk, Felix Schindler
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
#ifndef DUNE_STUFF_TEST_MAIN_HH
#warning This header is deprecated, include <dune/stuff/test/main.hxx> instead
#define DUNE_STUFF_TEST_MAIN_HH
#include
"config.h"
#include
<dune/stuff/test/main.hxx>
#include
<string>
#include
<vector>
#include
<map>
#include
<random>
#include
<fstream>
#include
<sys/time.h>
#include
<dune/stuff/common/disable_warnings.hh>
#include
<dune/stuff/test/gtest/gtest.h>
#include
<dune/common/float_cmp.hh>
#include
<dune/common/fvector.hh>
#include
<dune/common/fmatrix.hh>
#include
<dune/common/tuples.hh>
#include
<dune/common/tupleutility.hh>
#include
<dune/common/parallel/mpihelper.hh>
#if HAVE_DUNE_FEM
#include
<dune/fem/misc/mpimanager.hh>
#endif
#include
<dune/stuff/common/reenable_warnings.hh>
#include
<dune/stuff/aliases.hh>
#include
<dune/stuff/common/configuration.hh>
#include
<dune/stuff/common/logging.hh>
#include
<dune/stuff/common/convergence-study.hh>
static
void
check_for_success
(
const
Dune
::
Stuff
::
Common
::
ConvergenceStudy
&
study
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
double
>>&
errors_map
)
{
for
(
const
auto
&
norm
:
study
.
used_norms
())
{
const
auto
expected_results
=
study
.
expected_results
(
norm
);
const
auto
errors_search
=
errors_map
.
find
(
norm
);
EXPECT_NE
(
errors_search
,
errors_map
.
end
())
<<
" norm = "
<<
norm
;
const
auto
&
errors
=
errors_search
->
second
;
EXPECT_LE
(
errors
.
size
(),
expected_results
.
size
())
<<
" norm = "
<<
norm
;
for
(
size_t
ii
=
0
;
ii
<
errors
.
size
();
++
ii
)
EXPECT_LE
(
errors
[
ii
],
expected_results
[
ii
])
<<
" norm = "
<<
norm
<<
", level = "
<<
ii
;
}
}
// ... check_for_success(...)
class
DUNE_DEPRECATED_MSG
(
"Use the expectation macros of the gtest test suite (20.08.2014)!"
)
errors_are_not_as_expected
:
public
Dune
::
Exception
{
};
std
::
vector
<
double
>
DUNE_DEPRECATED_MSG
(
"Use the expectation macros of the gtest test suite (20.08.2014)!"
)
truncate_vector
(
const
std
::
vector
<
double
>&
in
,
const
size_t
size
)
{
assert
(
size
<=
in
.
size
());
if
(
size
==
in
.
size
())
return
in
;
else
{
std
::
vector
<
double
>
ret
(
size
);
for
(
size_t
ii
=
0
;
ii
<
size
;
++
ii
)
ret
[
ii
]
=
in
[
ii
];
return
ret
;
}
}
// ... truncate_vector(...)
template
<
template
<
class
>
class
Test
>
struct
TestRunner
{
struct
Visitor
{
template
<
class
T
>
void
visit
(
const
T
&
)
{
Test
<
T
>
().
run
();
}
};
template
<
class
Tuple
>
static
void
run
()
{
Tuple
t
;
Dune
::
ForEachValue
<
Tuple
>
fe
(
t
);
Visitor
v
;
fe
.
apply
(
v
);
}
};
// struct TestRunner
template
<
int
i
>
struct
Int
{
static
const
int
value
=
i
;
};
//! where sleep only counts toward wall time, this wastes actual cpu time
void
busywait
(
const
int
ms
)
{
// "round" up to next full 10 ms to align with native timer res
const
int
milliseconds
=
(
ms
/
10
)
*
10
+
10
;
timeval
start
,
end
;
gettimeofday
(
&
start
,
NULL
);
do
{
gettimeofday
(
&
end
,
NULL
);
}
while
(((
end
.
tv_sec
-
start
.
tv_sec
)
*
1e6
)
+
((
end
.
tv_usec
-
start
.
tv_usec
))
<
milliseconds
*
1000
);
}
typedef
Dune
::
tuple
<
double
,
float
// , Dune::bigunsignedint
,
int
,
unsigned
int
,
unsigned
long
,
long
long
,
char
>
BasicTypes
;
int
main
(
int
argc
,
char
**
argv
)
{
#ifdef DUNE_STUFF_TEST_MAIN_CATCH_EXCEPTIONS
try
{
#endif
testing
::
InitGoogleTest
(
&
argc
,
argv
);
DSC_CONFIG
.
read_options
(
argc
,
argv
);
#if HAVE_DUNE_FEM
Dune
::
Fem
::
MPIManager
::
initialize
(
argc
,
argv
);
#else
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
#endif
DSC
::
Logger
().
create
(
#ifdef DUNE_STUFF_TEST_MAIN_ENABLE_INFO_LOGGING
DSC
::
LOG_CONSOLE
|
DSC
::
LOG_INFO
|
DSC
::
LOG_ERROR
#else
DSC
::
LOG_CONSOLE
|
DSC
::
LOG_ERROR
#endif
,
""
,
""
,
""
);
return
RUN_ALL_TESTS
();
#ifdef DUNE_STUFF_TEST_MAIN_CATCH_EXCEPTIONS
}
catch
(
Dune
::
Exception
&
e
)
{
std
::
cerr
<<
"
\n
Dune reported error: "
<<
e
.
what
()
<<
std
::
endl
;
std
::
abort
();
}
catch
(
std
::
exception
&
e
)
{
std
::
cerr
<<
"
\n
"
<<
e
.
what
()
<<
std
::
endl
;
std
::
abort
();
}
catch
(...)
{
std
::
cerr
<<
"Unknown exception thrown!"
<<
std
::
endl
;
std
::
abort
();
}
// try
#endif // DUNE_STUFF_TEST_MAIN_CATCH_EXCEPTIONS
}
// ... main(...)
#endif // DUNE_STUFF_TEST_MAIN_HH
This diff is collapsed.
Click to expand it.
dune/stuff/test/main.hxx
0 → 100644
+
165
−
0
View file @
09fa8122
// This file is part of the dune-stuff project:
// https://github.com/wwu-numerik/dune-stuff
// Copyright holders: Rene Milk, Felix Schindler
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
#ifndef DUNE_STUFF_TEST_MAIN_HXX
#define DUNE_STUFF_TEST_MAIN_HXX
#include
"config.h"
#include
<string>
#include
<vector>
#include
<map>
#include
<random>
#include
<fstream>
#include
<sys/time.h>
#include
<dune/stuff/common/disable_warnings.hh>
#include
<dune/stuff/test/gtest/gtest.h>
#include
<dune/common/float_cmp.hh>
#include
<dune/common/fvector.hh>
#include
<dune/common/fmatrix.hh>
#include
<dune/common/tuples.hh>
#include
<dune/common/tupleutility.hh>
#include
<dune/common/parallel/mpihelper.hh>
#if HAVE_DUNE_FEM
#include
<dune/fem/misc/mpimanager.hh>
#endif
#include
<dune/stuff/common/reenable_warnings.hh>
#include
<dune/stuff/aliases.hh>
#include
<dune/stuff/common/configuration.hh>
#include
<dune/stuff/common/logging.hh>
#include
<dune/stuff/common/convergence-study.hh>
static
void
check_for_success
(
const
Dune
::
Stuff
::
Common
::
ConvergenceStudy
&
study
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
double
>>&
errors_map
)
{
for
(
const
auto
&
norm
:
study
.
used_norms
())
{
const
auto
expected_results
=
study
.
expected_results
(
norm
);
const
auto
errors_search
=
errors_map
.
find
(
norm
);
EXPECT_NE
(
errors_search
,
errors_map
.
end
())
<<
" norm = "
<<
norm
;
const
auto
&
errors
=
errors_search
->
second
;
EXPECT_LE
(
errors
.
size
(),
expected_results
.
size
())
<<
" norm = "
<<
norm
;
for
(
size_t
ii
=
0
;
ii
<
errors
.
size
();
++
ii
)
EXPECT_LE
(
errors
[
ii
],
expected_results
[
ii
])
<<
" norm = "
<<
norm
<<
", level = "
<<
ii
;
}
}
// ... check_for_success(...)
class
DUNE_DEPRECATED_MSG
(
"Use the expectation macros of the gtest test suite (20.08.2014)!"
)
errors_are_not_as_expected
:
public
Dune
::
Exception
{
};
std
::
vector
<
double
>
DUNE_DEPRECATED_MSG
(
"Use the expectation macros of the gtest test suite (20.08.2014)!"
)
truncate_vector
(
const
std
::
vector
<
double
>&
in
,
const
size_t
size
)
{
assert
(
size
<=
in
.
size
());
if
(
size
==
in
.
size
())
return
in
;
else
{
std
::
vector
<
double
>
ret
(
size
);
for
(
size_t
ii
=
0
;
ii
<
size
;
++
ii
)
ret
[
ii
]
=
in
[
ii
];
return
ret
;
}
}
// ... truncate_vector(...)
template
<
template
<
class
>
class
Test
>
struct
TestRunner
{
struct
Visitor
{
template
<
class
T
>
void
visit
(
const
T
&
)
{
Test
<
T
>
().
run
();
}
};
template
<
class
Tuple
>
static
void
run
()
{
Tuple
t
;
Dune
::
ForEachValue
<
Tuple
>
fe
(
t
);
Visitor
v
;
fe
.
apply
(
v
);
}
};
// struct TestRunner
template
<
int
i
>
struct
Int
{
static
const
int
value
=
i
;
};
//! where sleep only counts toward wall time, this wastes actual cpu time
void
busywait
(
const
int
ms
)
{
// "round" up to next full 10 ms to align with native timer res
const
int
milliseconds
=
(
ms
/
10
)
*
10
+
10
;
timeval
start
,
end
;
gettimeofday
(
&
start
,
NULL
);
do
{
gettimeofday
(
&
end
,
NULL
);
}
while
(((
end
.
tv_sec
-
start
.
tv_sec
)
*
1e6
)
+
((
end
.
tv_usec
-
start
.
tv_usec
))
<
milliseconds
*
1000
);
}
typedef
Dune
::
tuple
<
double
,
float
// , Dune::bigunsignedint
,
int
,
unsigned
int
,
unsigned
long
,
long
long
,
char
>
BasicTypes
;
int
main
(
int
argc
,
char
**
argv
)
{
#ifdef DUNE_STUFF_TEST_MAIN_CATCH_EXCEPTIONS
try
{
#endif
testing
::
InitGoogleTest
(
&
argc
,
argv
);
DSC_CONFIG
.
read_options
(
argc
,
argv
);
#if HAVE_DUNE_FEM
Dune
::
Fem
::
MPIManager
::
initialize
(
argc
,
argv
);
#else
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
#endif
DSC
::
Logger
().
create
(
#ifdef DUNE_STUFF_TEST_MAIN_ENABLE_INFO_LOGGING
DSC
::
LOG_CONSOLE
|
DSC
::
LOG_INFO
|
DSC
::
LOG_ERROR
#else
DSC
::
LOG_CONSOLE
|
DSC
::
LOG_ERROR
#endif
,
""
,
""
,
""
);
return
RUN_ALL_TESTS
();
#ifdef DUNE_STUFF_TEST_MAIN_CATCH_EXCEPTIONS
}
catch
(
Dune
::
Exception
&
e
)
{
std
::
cerr
<<
"
\n
Dune reported error: "
<<
e
.
what
()
<<
std
::
endl
;
std
::
abort
();
}
catch
(
std
::
exception
&
e
)
{
std
::
cerr
<<
"
\n
"
<<
e
.
what
()
<<
std
::
endl
;
std
::
abort
();
}
catch
(...)
{
std
::
cerr
<<
"Unknown exception thrown!"
<<
std
::
endl
;
std
::
abort
();
}
// try
#endif // DUNE_STUFF_TEST_MAIN_CATCH_EXCEPTIONS
}
// ... main(...)
#endif // DUNE_STUFF_TEST_MAIN_HXX
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